Often there is a need to append Terms and Conditions (T&C) to a printed purchase order or invoice in Dynamics 365 for Finance and Operations. Instead of printing them as the last pages of a generated document, you can also email T&C along the printed purchase order or invoice.
While our reporting add-on for D365FO Docentric AX covers both scenarios, in this article we will focus on printing T&C as the integral part of a resulting document. We will discuss two different approaches on the example of the Purchase order report.
Terms and Conditions as the part of a Docentric template
The first approach is that T&C becomes the part of a Docentric template for the Purchase order report by being entered as the fixed (static) text, e.g. at the end of the template. This also means that each time when you want to change something in your Terms and Conditions, you need to edit the template itself. Since end-users can also update templates themselves anytime in production, this isn’t really a drawback.
This approach works just fine if you don’t have multiple variants of T&C depending on, e.g. the related vendor or the language. In that case, you would need to show them conditionally, i.e. to employ IF tagging elements to show different parts of the template containing different variants of T&C. This might become cumbersome if you have too many different T&Cs, especially if they occupy multiple pages. If this is true, then we suggest taking the second approach.
Terms and Conditions as the part of a report data source
The second approach is to provide T&C as a part of the report data source and then use the SUBDOCUMENT tagging element in the template to show it. We plan to enable this as a feature in one of the next releases: setting up subdocuments as part of report data sources in Docentric report setup. However, right now adding of T&C as a subdocument can be done through X++ in Purchase order’s DSP class.
Bellow is a sample code on how to do it in the existing Purchase order’s DSP class (DocPurchPurchaseOrderReportDSP) that you can find in our Docentric AX SSRS Replicas model.
private void addDataFieldsForHeader(DocXmlRecord _addingRecord,
DocXmlRecord subDocumentsDataRecord =
while select docuRef where
docuRef.RefTableId == purchTable.TableId &
docuRef.RefRecId == purchTable.RecId &
docuRef.TypeId == 'File'
using (System.IO.Stream docuRefStream =
using (System.IO.MemoryStream subdocMs = new System.IO.MemoryStream())
docuRefStream.Position = 0;
Note that this code will add all attachments from the current purchase order, so you need to make additional filtering in order to select only those attachments representing T&Cs (or just the single one).
When we regenerate the DDSP file using the changed DSP class for Purchase order, and load it to the Purchase order’s template, we will see that the new data record Subdocuments appeared in the data source. After we bind it to a newly inserted Subdocument tagging element, we can preview the document and see the result.
Note that you can also introduce a different page layout when T&C starts by inserting a section break in MS Word, so the result could look like the following:
There is more: Subdocuments as Word or HTML
Docentric supports two types of subdocuments: Word and HTML. HTML could also be a smart choice if you want to provide dynamic HTML formatted parts of generating documents, similar to built-in Form notes, only that Form notes contain plain (not-formatted) text.
In one of the next releases, we will introduce enhancements of built-in Form notes, so that you will be able to enter your T&C here and format them using the same rich text editor you already use for editing the email body when emailing reports or Email templates.
Until then, you can attach T&Cs and other documents provided as Word documents to a particular report type on the Form notes form, and append them as subdocuments in the corresponding report’s DSP class.
We are always happy to hear your feedback, ideas and scenarios! Feel free to tell us all about them here or write us to firstname.lastname@example.org.