Effortless Dataverse/CRM Document Template Migration with KingswaySoft

18 December 2025
KingswaySoft Team

Document Templates in Dynamics 365 Dataverse/CRM are essential, standardized Microsoft Word and Excel files that allow users to generate data-populated documents, such as contracts and reports, directly from records. They ensure brand consistency and save significant time, and with the click of a button, you can generate reports for a specific set of records in a readable, professional business format. 

When it comes to migrating these document templates, this can be easily done by using the components in our SSIS Integration Toolkit for Dynamics 365. To achieve this, connect to your Dataverse/CRM instances, use a Source component to read from the documenttemplate entity in your source connection, and then write to the same entity using an appropriate write action in the Destination component connected to the target instance.

Now, this is generally a straightforward process. Typically, you would map the required metadata from source to destination, including the primary GUID, the entity code for the associated entity, the name of the document template, etc. This entire process will likely take you only a few minutes to complete if you are working with a system entity. 

However, when working with document templates that target a custom entity, a special challenge occurs: a Dataverse/CRM custom entity can have a different entity code across two instances. Because of this, the output value of the associatedentitytypecode field in the source component might point to a completely different entity in the target instance. So, if you are doing a straight write to the documenttemplate entity in a different instance that involves a custom entity, it might end up creating or updating a document template record that is associated with the wrong entity in the target instance. Since the target entity code (integer) is actually saved in the document template file, an incorrect entity code will make the migrated template unusable.

The good news is, this specific situation can be handled by our components, through the use of an artificial field calledassociatedentitytypecode.old. This field is made available specifically to overcome the problem by looking for the entity code referenced in the document template and replacing it with the correct entity code before saving the template to the target instance. All the magic happens automatically within our software when you have the original associated entity's type code from your source system passed to the destination component. With the correct associatedentitytypecode.old field provided, our toolkit intelligently rewrites the template's file content to associate all occurrences of the original entity to the correct new entity code in the target Dataverse/CRM instance. This ensures the template file is correctly associated.

In this blog post, we will see an example of how proper document template migration is performed using KingswaySoft.

Source Dataverse/CRM configuration

In our demonstration, we are considering the migration of a document template from an On-premises Dataverse/CRM instance to an Online Dataverse/CRM instance. In your On-prem source, let's assume that the document template below is one of the many that you have with custom and out-of-the-box entities associated with each respectively. In this case, the document template in focus is called cust_client_template.

CRM on prem document templates.png

When you open it, the associated entity is denoted by an Associated Entity Type Code, and in this case, it's a custom entity called cust_client.

on prem template showing associated entity.png

Our aim is to migrate the document template above with the same GUIDs and other metadata to the target online instance, while preserving the entity it is associated with.

Target Dataverse/CRM customization

In your Target instance, you would make sure that the same custom entity has been created. This can be done manually or through the import of your customization solution exported from the source instance.

CRM online custom entity.png

Once you have published all customizations, we are ready to move on to our SSIS data flow design.

Data Flow Design 

In your SSIS package, you would be working with two instances, thereby two connection managers: one for your source and the other for your target instance. Note that the connection managers we use are the Dynamics 365 Dataverse/CRM ones; however, they are valid for Dataverse connections as well.

Source and Target connections.png

The strategy here would be:

Step 1: Read the documenttemplate entity from your Source Dataverse/CRM instance

Step 2: Get the ObjectTypeCodes for the associated entities from the Source, which will be used as the input of the associatedentitytypecode.old field in Step 3 below.

Step 3: Write to Target Online instance to create new documenttemplate record, while maintaining the associations with the custom entity by having both the  associatedentitytypecode and  associatedentitytypecode.old fields mapped.

The Data Flow Design would look as shown below. Let's look at the steps in detail.

Step 1 is straightforward; you would use a Dataverse/CRM Source component and pull the records from the DocumentTemplate entity. You can also use a fetchXML if you wish to read specific records or a specific range.

Step 2, however, would require an important additional column called ObjectTypeCode (which is an integer value and different from the associatedentitytypecode from the source). This would be a unique number assigned by the Source Dataverse/CRM for the entity you are associating the document template with, to be written to the associatedentitytypecode.old field in the Dataverse/CRM Destination. Since in a real-life migration scenario you would have numerous templates and their respective associated entities, it wouldn't be viable to have a list of integer values hardcoded in the design. Therefore, we would use a lookup mechanism to get these object type codes. The lookup can be performed against the EntityMetadata entity, which KingswaySoft's Dataverse/CRM source component supports, from which you can retrieve each entity's logicalName and ObjectTypeCode.

SourceEntityMetadata.png

EntityMetadata Columns.png

We use the Dataverse/CRM Source from Step 1 as the primary source of the data low, and lookup against the above EntityMetadata source, using our Premium Lookup component (which comes as a part of our SSIS Productivity Pack). The entity name related field from each Source components can be used as the Key to join and get the ObjectTypeCode for each available entity to be written to the Destination. 

Lookup Matching Key.png

Step 3 would involve writing to the Target instance using the Dataverse/CRM Destination component. In here, you would choose the entity documenttemplate to perform a Create action (or an Upsert action if that makes more sense).

Write to CRM Online.png

On the columns page, you could map the required metadata, including the associatedentitytypecode.old field, which is an arbitrary field added by us in the Dataverse/CRM destination component to specifically handle the document conversion from the old object type code to the new one in the target instance. The Lookup.ObjectTypeCode is the integer value that we get as a part of the Lookup in step 2.

CRM Destination Columns.png

Once it is executed, the new document templates will be created in the target Dataverse/CRM instance and can be verified from the Dataverse/CRM side.

New Template List.png

Conclusion 

The availability of the associatedentitytypecode.old field in the  KingswaySoft Dynamics 365 Dataverse/CRM destination represents a significant advancement in template management when working with the documenttemplate entity. This feature ensures the reliable, automated migration of all document templates, safeguarding data integrity and accelerating deployment cycles, particularly for custom entities.

We hope this has helped!

Archive

December 2025 1 November 2025 2 October 2025 2 September 2025 2 August 2025 2 July 2025 2 June 2025 1 May 2025 2 April 2025 3 March 2025 1 February 2025 1 January 2025 2 December 2024 1 November 2024 3 October 2024 1 September 2024 1 August 2024 2 July 2024 1 June 2024 1 May 2024 1 April 2024 2 March 2024 2 February 2024 2 January 2024 2 December 2023 1 November 2023 1 October 2023 2 August 2023 1 July 2023 2 June 2023 1 May 2023 2 April 2023 1 March 2023 1 February 2023 1 January 2023 2 December 2022 1 November 2022 2 October 2022 2 September 2022 2 August 2022 2 July 2022 3 June 2022 2 May 2022 2 April 2022 3 March 2022 2 February 2022 1 January 2022 2 December 2021 1 October 2021 1 September 2021 2 August 2021 2 July 2021 2 June 2021 1 May 2021 1 April 2021 2 March 2021 2 February 2021 2 January 2021 2 December 2020 2 November 2020 4 October 2020 1 September 2020 3 August 2020 2 July 2020 1 June 2020 2 May 2020 1 April 2020 1 March 2020 1 February 2020 1 January 2020 1 December 2019 1 November 2019 1 October 2019 1 May 2019 1 February 2019 1 December 2018 2 November 2018 1 October 2018 4 September 2018 1 August 2018 1 July 2018 1 June 2018 3 April 2018 3 March 2018 3 February 2018 3 January 2018 2 December 2017 1 April 2017 1 March 2017 7 December 2016 1 November 2016 2 October 2016 1 September 2016 4 August 2016 1 June 2016 1 May 2016 3 April 2016 1 August 2015 1 April 2015 10 August 2014 1 July 2014 1 June 2014 2 May 2014 2 February 2014 1 January 2014 2 October 2013 1 September 2013 2 August 2013 2 June 2013 5 May 2013 2 March 2013 1 February 2013 1 January 2013 1 December 2012 2 November 2012 2 September 2012 2 July 2012 1 May 2012 3 April 2012 2 March 2012 2 January 2012 1

Tags