Dynamically chosen Report logo
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
Filed under: c/al, logo, nav 2009, nav reporting Tagged: c/al, logo, nav 2009, report

Like
Report
*This post is locked for comments