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 | CustomerIF SalesSetup."Logo Position on Documents" = SalesSetup."Logo Position on Documents"::Right THEN BEGINcustomer.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 <> '' THENCLEAR(CompanyInfo1.Picture); IF CompanyInfo2.Name <> '' THENCLEAR(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:
1DataItemSales Invoice HeaderNo
0Column“No.”No_SalesInvHdrNo
…
1DataItemIntegerCopyLoopNo
1DataItemIntegerPageLoopNo
0ColumnCompanyInfo2.PictureCompanyInfo2PictureNo
0ColumnCompanyInfo1.PictureCompanyInfo1PictureNo
0ColumnCompanyInfo3.PictureCompanyInfo3PictureNo
…
the code:
OnInitReport()
…
FormatDocument.SetLogoPosition(SalesSetup.”Logo Position on Documents”,CompanyInfo1,CompanyInfo2,CompanyInfo3);
so edit cu 368, change fct. SetLogoPosition for your needs.
LikeLike