How to add the dashboard image banner to all Docentric report templates by adding it to the GeneralData section

Intro

In this post we’ll show an example of how to make some data available to be added to all Docentric report templates.

Usually, the main data of a report is different per report, but sometiems it’s useful to have some non report-specific data available, for example, company-related information, like the company logo:

Working example

In this working example, we’ll add the dashboard image, that can be set on every legal entity, to the GeneralData/CurrentCompany section of the Schema of all Docentric report templates.

  1. First we need to set the dashboard image in the D365FO UI, in this case, we’re setting the image type to be Banner:

  2. Next, we need to create a small custom class, that will extend the base DocDataSourceProviderBase class:

[ExtensionOf(classStr(DocDataSourceProviderBase))]
final class DocDataSourceProviderBase_Extension
{
    protected void addGeneralDataSectionBaseCompanyInfo(DocXmlRecord _currentCompanyDataRecord, CompanyInfo _currentCompanyInfo)
    {
        next addGeneralDataSectionBaseCompanyInfo(_currentCompanyDataRecord, _currentCompanyInfo);

        CompanyImage companyImage = CompanyImage::findByRecord(_currentCompanyInfo, false, CompanyImageType::DashboardBanner);

        _currentCompanyDataRecord.addCalculatedField('Banner', companyImage.Image, 'Company Banner');
    }
}
  1. Now, we’ll need to generate the DDSP of the report we’re designing, in this example Sales Invoice, by firstly setting the Print destination of the report to be the Docentric Generate DS:

  2. Then we can simply print the report and we’ll get the DDSP file:

  3. Lastly, we will load the this DDSP into our Docentric template that we’re designing:

This is all that is needed to make the Banner image available in the Docentric template:

Outro

In this example we added data to the GeneralData/CompanytInfo section by using the addGeneralDataSectionBaseCompanyInfo(), but we can also add info to the other sections found under GeneralData by using the following methods:

  • addGeneralDataSectionBaseWorkerInfo() – to add data to the CurrentWorker section.
  • addGeneralDataSectionBaseMiscInfo() – to add data to the Misc section.
  • addGeneralDataSectionBase() – to add data to the base GeneralData section.

You can use the same basic premise as shown in this code example to add images that are also located outside of D365FO, you’ll just need to fetch them and convert them to a container.
To see the same example, but using an image located on SharePoint, check out this forum post: