Options

Variable value passed to report is not being printed

catiamatos1991catiamatos1991 Member Posts: 158
edited 2018-05-30 in NAV Three Tier
So I'm trying to display my variable value in my report. But it prints in the message "Numerario" but in the report is not showing anything..

OnPreDataItem()
PaymentMethodCode:=CustLedgEntry2."Payment Method Code";
PaymentMethod.GET(PaymentMethodCode);
PaymentMethodDescription:=PaymentMethod.Description;
MESSAGE('%1',PaymentMethodDescription);

https://us.v-cdn.net/5022383/uploads/editor/ew/3y66qx8ovy4u.png

My var PaymentMethodDescription have the option "Include in dataset to true"

---

ALL CODE UPDATED:

Documentation()

OnInitReport()
ShowLogo := TRUE; // LACT - jorge.rocha -> TRUE: show company logo

OnPreReport()

OnPostReport()

Cust. Ledger Entry - OnPreDataItem()
CompanyInfo.GET;
FormatAddr.Company(CompanyAddr,CompanyInfo);
GLSetup.GET;

ReportFooterCompany := STRSUBSTNO(ReportFooterCompanyLbl,CompanyInfo."Social Capital", CompanyInfo."VAT Registration No.", CompanyInfo."Registration Authority", CompanyInfo."Comercial Registration No.");


Cust. Ledger Entry - OnAfterGetRecord()
Cust.GET("Customer No.");
FormatAddr.Customer(CustAddr,Cust);

IF (CustLedgEntry2."Payment Method Code"='') THEN
PaymentMethod.INIT
ELSE BEGIN
PaymentMethodCode:=CustLedgEntry2."Payment Method Code";
PaymentMethod.GET(PaymentMethodCode);
PaymentMethodDescription:=PaymentMethod.Description;
END;

IF NOT Currency.GET("Currency Code") THEN
Currency.InitRoundingPrecision;

IF "Document Type" = "Document Type"::Payment THEN BEGIN
ReportTitle := Text003;
PaymentDiscountTitle := Text006;
END ELSE BEGIN
ReportTitle := Text004;
PaymentDiscountTitle := Text007;
END;

CALCFIELDS("Original Amount");
RemainingAmount := -"Original Amount";

Signature := ReportCertificate + CompanyInfo."Soft. Certificate Number" + ReportCode;


Cust. Ledger Entry - OnPostDataItem()

PageLoop - OnPreDataItem()

PageLoop - OnAfterGetRecord()

PageLoop - OnPostDataItem()

DetailedCustLedgEntry1 - OnPreDataItem()

DetailedCustLedgEntry1 - OnAfterGetRecord()

DetailedCustLedgEntry1 - OnPostDataItem()

CustLedgEntry1 - OnPreDataItem()

CustLedgEntry1 - OnAfterGetRecord()
IF "Entry No." = "Cust. Ledger Entry"."Entry No." THEN
CurrReport.SKIP;

PmtDiscInvCurr := 0;
PmtTolInvCurr := 0;
PmtDiscPmtCurr := 0;
PmtTolPmtCurr := 0;

ShowAmount := -DetailedCustLedgEntry1.Amount;

IF "Cust. Ledger Entry"."Currency Code" <> "Currency Code" THEN BEGIN
PmtDiscInvCurr := ROUND("Pmt. Disc. Given (LCY)" * "Original Currency Factor");
PmtTolInvCurr := ROUND("Pmt. Tolerance (LCY)" * "Original Currency Factor");
AppliedAmount :=
ROUND(
-DetailedCustLedgEntry1.Amount / "Original Currency Factor" *
"Cust. Ledger Entry"."Original Currency Factor",Currency."Amount Rounding Precision");
END ELSE BEGIN
PmtDiscInvCurr := ROUND("Pmt. Disc. Given (LCY)" * "Cust. Ledger Entry"."Original Currency Factor");
PmtTolInvCurr := ROUND("Pmt. Tolerance (LCY)" * "Cust. Ledger Entry"."Original Currency Factor");
AppliedAmount := -DetailedCustLedgEntry1.Amount;
END;

PmtDiscPmtCurr := ROUND("Pmt. Disc. Given (LCY)" * "Cust. Ledger Entry"."Original Currency Factor");
PmtTolPmtCurr := ROUND("Pmt. Tolerance (LCY)" * "Cust. Ledger Entry"."Original Currency Factor");

RemainingAmount := (RemainingAmount - AppliedAmount) + PmtDiscPmtCurr + PmtTolPmtCurr;

CustLedgEntry1 - OnPostDataItem()

DetailedCustLedgEntry2 - OnPreDataItem()

DetailedCustLedgEntry2 - OnAfterGetRecord()

DetailedCustLedgEntry2 - OnPostDataItem()

CustLedgEntry2 - OnPreDataItem()

CustLedgEntry2 - OnAfterGetRecord()
IF "Entry No." = "Cust. Ledger Entry"."Entry No." THEN
CurrReport.SKIP;

PmtDiscInvCurr := 0;
PmtTolInvCurr := 0;
PmtDiscPmtCurr := 0;
PmtTolPmtCurr := 0;

ShowAmount := DetailedCustLedgEntry2.Amount;

IF "Cust. Ledger Entry"."Currency Code" <> "Currency Code" THEN BEGIN
PmtDiscInvCurr := ROUND("Pmt. Disc. Given (LCY)" * "Original Currency Factor");
PmtTolInvCurr := ROUND("Pmt. Tolerance (LCY)" * "Original Currency Factor");
END ELSE BEGIN
PmtDiscInvCurr := ROUND("Pmt. Disc. Given (LCY)" * "Cust. Ledger Entry"."Original Currency Factor");
PmtTolInvCurr := ROUND("Pmt. Tolerance (LCY)" * "Cust. Ledger Entry"."Original Currency Factor");
END;

PmtDiscPmtCurr := ROUND("Pmt. Disc. Given (LCY)" * "Cust. Ledger Entry"."Original Currency Factor");
PmtTolPmtCurr := ROUND("Pmt. Tolerance (LCY)" * "Cust. Ledger Entry"."Original Currency Factor");

AppliedAmount := DetailedCustLedgEntry2.Amount;

//RemainingAmount := (RemainingAmount - AppliedAmount) + PmtDiscPmtCurr + PmtTolPmtCurr; // LACT commented


CustLedgEntry2 - OnPostDataItem()

Total - OnPreDataItem()

Total - OnAfterGetRecord()

Total - OnPostDataItem()

Gen. Journal Line - OnPreDataItem()

Gen. Journal Line - OnAfterGetRecord()

Gen. Journal Line - OnPostDataItem()

LOCAL CurrencyCode(SrcCurrCode : Code[10]) : Code[10]
IF SrcCurrCode = '' THEN
EXIT(GLSetup."LCY Code");
EXIT(SrcCurrCode);

Answers

  • Options
    DrakonianDrakonian Member Posts: 14
    edited 2018-05-29
    Hello, it is not working because OnPost trigger not taken into account in shaping DataSet.
    Move the code to OnAfterGetRecord trigger.
    And pay attention at each iteration, it is overwritten.
  • Options
    catiamatos1991catiamatos1991 Member Posts: 158
    But there the message is empty
  • Options
    DrakonianDrakonian Member Posts: 14
    edited 2018-05-30
    Try to change variable CustLedgEntry2 to DataItem name "Cust. Ledger Entry". And look msg
    IF "Cust. Ledger Entry"."Payment Method Code"= '' THEN
      PaymentMethod.INIT
      MESSAGE('Empty Payment Method Code');
    END ELSE BEGIN
      PaymentMethodCode:="Cust. Ledger Entry"."Payment Method Code";
      PaymentMethod.GET(PaymentMethodCode);
      PaymentMethodDescription:=PaymentMethod.Description;
      Message('PaymentMethodCode %1',"Cust. Ledger Entry"."Payment Method Code");
    END;
    

    Also you can moove this code to CustLedgEntry2 DataItem without changes.

    You just try to call wrong DataItem.
  • Options
    catiamatos1991catiamatos1991 Member Posts: 158
    Now I can get the message again but nothing in the report.. maybe am I printing with the wrong expression?
  • Options
    DrakonianDrakonian Member Posts: 14
    edited 2018-05-30
    For correct work you need to get expression like it
    =Last(Fields!PaymentMethodCode.Value)
    
    But do not forget, if you announced variable on CustLedgEntry2 DataItem on Layout you can get Value only on group by CustLedgEntry2 and deeper groups. If you need to get value elsewhere look at GetData and SetData function in layout.
    Also you can use ReportItems! (for footer/header).

  • Options
    catiamatos1991catiamatos1991 Member Posts: 158
    edited 2018-06-04
    I want to use PaymentMethodDesc, I'm confused with you answer @Drakonian bsjsd78ax89h.png
    Is not showing anything...
  • Options
    DrakonianDrakonian Member Posts: 14
    @catiamatos1991 when you write =Last(Fields!PaymentMethodDesc.Value, "DataSet_Result")
    you try to get value from LAST line from all DataSet lines. That is, it will always be static and possibly even empty.

    For correct work create textbox inside table group, write
    =Last(Fields!PaymentMethodDesc.Value)
    
    check textbox name, example textbox42

    then create textbox on header, and write
    =ReportItems!textbox42.Value
    

    Also, you need put first textbox in right place.
  • Options
    Mohamed_ZayedMohamed_Zayed Member Posts: 39
    THANK YOU ALOT!!!!!!!!!!!!!!!!!!!! The "LAST" Funktion solved my problem!!!!!
  • Options
    Mohamed_ZayedMohamed_Zayed Member Posts: 39
    Drakonian wrote: »
    For correct work you need to get expression like it
    =Last(Fields!PaymentMethodCode.Value)
    
    But do not forget, if you announced variable on CustLedgEntry2 DataItem on Layout you can get Value only on group by CustLedgEntry2 and deeper groups. If you need to get value elsewhere look at GetData and SetData function in layout.
    Also you can use ReportItems! (for footer/header).

    Thanks again!!!!
Sign In or Register to comment.