Some time ago, the Cross-company data feature was released. With this introduction, it is now also possible to include templates from other company files directly into your PDF export.
This is particularly useful when creating consolidated Annual Accounts for instance, to include specific templates from a non-consolidated holding entity, or for other multi-company PDF exports.
How does it work?
Company selector (optional)
The first (optional) step is to add an external company selector in a template (e.g. in a “General Settings” template). This allows users to filter and select the specific company file(s) that should be included in the PDF export.
You can find more technical details on the company selector here.
Code example
The actual export of templates is handled within the Detail text section of an Export Style. This section is where rendered templates are “printed” to the PDF.
Below you will find an example of code that can be in the Detail text section, this example is used to export both consolidated and non-consolidated templates from two different company files.
{% assign general_settings = period.reconciliations.general_settings %}
{% comment %}In this example we are referring to a General settings template which contains a external company selector{% endcomment %}
{% comment %}==consolidated templates first (current file)=={% endcomment %}
{% unless export.current_title contains '_external' %}
{% comment %} --- Template collection ---
How collections of templates are assigned differs per use case, therefor
in this example we are referring to [template collection]
{% endcomment %}
{% for handle in [template collection] %}
{% assign templates_to_export = export. selected_accounts_and_reconciliation_texts.reconciliation_texts.[handle] %}
{% for template in templates_to_export %}
{% comment%}Rendering the template content{% endcomment %}
{{ template.rendered_template }}
{% endfor %}
{% endfor %}
{% comment %}==non-consolidated templates second (external file)=={% endcomment %}
{% else %}{% comment %}on unless contains _external{% endcomment %}
{% assign external_company_selected = company.external_companies | range:general_settings.custom.external.companies %}
{% for company_selected in external_company_selected %}
{% assign external_company = company_selected %}
{% comment %}
Additional logic can be added here
{% endcomment %}
{% endfor %}
{% comment %} --- Template collection ---
How collections of templates are assigned differs per use case, therefor
in this example we are referring to [template collection external]{% endcomment %}
{% for handle in [template collection external] %}
{% assign templates_to_export_external = external_company.period.reconciliations[handle] %}
{% for template in templates_to_export_external %}
{% comment%}Rendering the template content{% endcomment %}
{{ template.rendered_template }}
{% endfor %}
{% endfor %}
{% endunless %}{% comment %}on check contains _external{% endcomment %}
Tip: For more information on template collection(s) in the Detail text, see here
We will now dive into the external companies specifics a bit deeper.
Accessing companies and exporting
First, you need to access the external_companies drop. If you are using a selector, you can filter the range based on those selections:
Code snippet
{% assign external_company_selected = company.external_companies | range:general_settings.custom.external.companies %}
{% for company_selected in external_company_selected %}
{% assign external_company = company_selected %}
{% comment %}
Additional logic can be added here
{% endcomment %}
{% endfor %}
Exporting specific templates
Once you have accessed the external company, you can assign the specific templates you wish to export. This is done by referencing the external_company, the period.reconciliations, and the specific handle of the template.
In the example below, we loop through an array of handles to export multiple templates:
Code snippet
{% for handle in handles_external %}
{% assign templates_to_export_external = external_company.period.reconciliations[handle] %}
{% comment %} --- Template collection ---
How collections of templates are assigned differs per use case, therefor in this example we are referring to [template collection external]{% endcomment %}
{% for template in [template collection external] %}
{% comment%}Rendering the template content{% endcomment %}
{{ template.rendered_template }}
{% endfor %}
{% endfor %}
Tip: For more information on template collection(s) in the Detail text, see here
Using different blocks (optional)
If you need to export external templates at a specific location, for example, after all current company templates, you can utilize different export blocks.
By adding a suffix like _external to the block title, you can filter and trigger these specific blocks using a check on export.current_title.
Important Considerations
While this workflow is useful to export external templates in a single PDF export, there are a few catches to keep in mind:
-
Manual (de)selection: The standard feature to (de)select templates inside a block when creating a PDF export does not work for external company templates. Therefore, we recommend controlling the inclusion/exclusion of templates via the template handles within the Detail text section of the export file.
-
Triggering sections: If the current company file does not contain a template in a specific export section (block), that section will not be triggered at all.
- Workaround: Select a “dummy” template (one that isn’t exported by your handle logic) inside that block in the Style settings. This ensures the section remains active.
Conclusion
Because PDF export styles vary significantly between use cases and countries, these examples are intended as a foundation for your own solution.
In some scenarios, it may be more efficient to simply pull data from another company into a template within the current file using the Cross-company data feature. We recommend experimenting with both approaches to see which best fits your reporting structure.