In standard NAV reports the company logo is shown in reports, if in setup page “sales & receivables setup” field “logo position on documents” has a value other than “no logo”. Also it’s needed, that there is an image loaded in the “company information”.
Display Customer Image instead of Company Image:
This article however deals with a different case. Assuming a client wants to display the customer logo on nav 2009 classic reports, e.g. report 206 “sales invoice report”. The customer logo is saved in field Picture of table customer. Table “sales invoice header” is the data base (dataitem) of this report. So we need field “Sell-to Customer No.” to check. The following code snippet can be a solution for that case. Let’s say, we want to swap the logo in the right, upper corner:
Create a new global variable CompInfoRight (property temporary=yes) in the report:
CompInfoRight | Record | Company Information
Then open the sections designer.
Change property SourceExpr of that right picture from CompanyInfo2.Picture to CompInfoRight.Picture.
Add following code to the trigger “Sales Invoice Header – OnAfterGetRecord()”:
// local variables // customer | record | Customer IF SalesSetup."Logo Position on Documents" = SalesSetup."Logo Position on Documents"::Right THEN BEGIN customer.GET("Sell-to Customer No."); customer.CALCFIELDS(Picture); IF customer.Picture.HASVALUE THEN CompInfoRight.Picture := customer.Picture; ELSE CompInfoRight.Picture := CompanyInfo2.Picture; END;
Another case: Hide Company logo
We don’t want to display a company logo on a report depending on a special customer. Then do the following:
Add text constant SkipCustomerNo to the report with the customer no. of that customer as value, e.g. 10000.
In trigger “Sales Invoice Header – OnAfterGetRecord()” add:
IF "Sell-to Customer No." = SkipCustomerNo THEN BEGIN CLEAR(CompanyInfo.Picture); IF CompanyInfo1.Name <> '' THEN CLEAR(CompanyInfo1.Picture); IF CompanyInfo2.Name <> '' THEN CLEAR(CompanyInfo2.Picture); END;
Do not use trigger OnInitReport for these code snippets, because on runtime when calling trigger OnIntReport the base dataitem “Sales Invoice Header” is not loaded. It is loaded, when trigger “Sales Invoice Header – OnAfterGetRecord()” is run.
cheers
Do you know if “Dynamically chosen Report logo” is possible in NAV 2017 using VisualStudio?
LikeLike
if you mean rdlc reports, then yes, it will work also with that. does not depend. rdlc reports also use c/al code. so you can use that in the same way.
LikeLike
Thanks for your answer.
Yes it’s a rdlc report (report 206).
The logo defends on the “Gen. Bus. Posting Group” on the “Sales Invoice header”.
My dataset is ok, I can see it passes the rigt logo, but I still can´t handle it i VS in the header.
I tried with getdata/setdata but it gives me an error due to the hidden property..
I solved it by making two reports with differents logo’s – not the perfect solution but i Works 🙂
LikeLike
should work with standard code and layout. so best do not change the report there.
the dataitem in report 206 sales invoice looks like:
1 DataItem Sales Invoice Header No
0 Column “No.” No_SalesInvHdr No
…
1 DataItem Integer CopyLoop No
1 DataItem Integer PageLoop No
0 Column CompanyInfo2.Picture CompanyInfo2Picture No
0 Column CompanyInfo1.Picture CompanyInfo1Picture No
0 Column CompanyInfo3.Picture CompanyInfo3Picture No
…
the code:
OnInitReport()
…
FormatDocument.SetLogoPosition(SalesSetup.”Logo Position on Documents”,CompanyInfo1,CompanyInfo2,CompanyInfo3);
so edit cu 368, change fct. SetLogoPosition for your needs.
LikeLike