Variable value passed to report is not being printed

catiamatos1991
Member Posts: 158
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);
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);
0
Answers
-
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.0 -
But there the message is empty0
-
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.1 -
Now I can get the message again but nothing in the report.. maybe am I printing with the wrong expression?0
-
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).
1 -
0
-
@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.0 -
THANK YOU ALOT!!!!!!!!!!!!!!!!!!!! The "LAST" Funktion solved my problem!!!!!0
-
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!!!!0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions