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