Get First Description

nhelnhel Member Posts: 39
Hi guyz,

I have just a problem with my report.
I want to capture the first description of the "Gen. Journal Line".Description and place it to the header.

This report in navision is Report ID # 2 "General Journal"

I put variable firstdesc then upon loading
i create this code

Body - OnPresection ()
if fistdesc = '' then
begin
firstdesc := "Gen. Journal Line".Description
end;

then i Place a control with source expression = firstdesc.


But i notice the first page dont have the description only the second page.
Thanks guys.

Comments

  • kinekine Member Posts: 12,562
    It is because the OnPreSection is called too early - before the first record is read. Try to use PostSection or another tirgger (like OnPreDataItem...)
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • David_CoxDavid_Cox Member Posts: 509
    Try:

    Body - OnPresection ()
    IF "Gen. Journal Line".FINDFIRST THEN
    firstdesc := "Gen. Journal Line".Description

    David
    Analyst Developer with over 17 years Navision, Contract Status - Busy
    Mobile: +44(0)7854 842801
    Email: david.cox@adeptris.com
    Twitter: https://twitter.com/Adeptris
    Website: http://www.adeptris.com
  • kinekine Member Posts: 12,562
    David Cox wrote:
    Try:

    Body - OnPresection ()
    IF "Gen. Journal Line".FINDFIRST THEN
    firstdesc := "Gen. Journal Line".Description

    David

    It looks as not good example, using DataItem variable to find some record in OnPresection of the body will lead into neverending loop... Because each time it will jump to the first record...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • David_CoxDavid_Cox Member Posts: 509
    kine wrote:
    David Cox wrote:
    Try:

    Body - OnPresection ()
    IF "Gen. Journal Line".FINDFIRST THEN
    firstdesc := "Gen. Journal Line".Description

    David

    It looks as not good example, using DataItem variable to find some record in OnPresection of the body will lead into neverending loop... Because each time it will jump to the first record...

    Ooops Quite right Kamil wrong place move the code to the DataItem:

    "Gen. Journal Line" - OnPreDataItem()
    IF FINDFIRST THEN
    firstdesc := "Gen. Journal Line".Description

    Another way is add a Group header and put the code in there

    GroupHeader - OnPresection ()

    IF CurrReport.SHOWOUTPUT THEN BEGIN
    firstdesc := "Gen. Journal Line".Description
    CurrReport.SHOWOUTPUT := FALSE;
    END;


    David
    Analyst Developer with over 17 years Navision, Contract Status - Busy
    Mobile: +44(0)7854 842801
    Email: david.cox@adeptris.com
    Twitter: https://twitter.com/Adeptris
    Website: http://www.adeptris.com
Sign In or Register to comment.