Migrate document templates across environments in Dynamics 365

Follow my blog for more interesting topics on Dynamics 365, Portals and Power Platform. For training and consulting, write to us at info@xrmforyou.com

It was just another day at my office and my client’s developer just walked up to me and asked – “How do I move my document templates to one environment to another?”. He seems to have manually uploaded in the target environment but that is not showing up the data in the target environment environment when then word template is downloaded.


If you have worked on word templates, you know that this will not work as the custom entity object type codes are different between the source and the target environment. If you are new to word templates, please remember that the entity in your word templates are reference by their object type codes instead of their logical name. So even though you migrated the solution, the object type code of the custom entity will most probably be different and hence this would not work out in the target environment.

So I asked him to use the wonderful XRM toolbox which has the ability to do the same.


Worked like a charm like all other XRM toolbox plugins.

But the ordeal does not end here. Every now and  then I get a question – “Can you explain what’s happening underneath? Can I do it without using a tool? Can you tell me where the changes are being made”.

Honestly I am not in favour of not using an utility when it is available. But if you want to dig deep, continue reading. Or may be you are getting an error with the tool and this might just save your day.

We all know the word and the excel files are essentially zip files. I just save my word template with .zip extension.


Now since its a .zip file, I can unzip the same.


In the folder I search for the object type code which in my case is 10426


I just open the three files in a XML editor of my choice and then replace my the object type code 10426 with the new objectypecode of the custom entity in the target environment – 10341

I save the files. And then i select all the contents and then re-zip it.


And then change the .zip extension to .docx extension.

And finally when you upload the template in the target environment, it just works fine.


I am not sure when you would do this manually but if you want to really do it and go under the hood, here it is for you.

And sometimes when you get an error, this way may just help you out.

Debajit Dutta

(Dynamics MVP)

For consultation/ corporate training visit www.xrmforyou.com or reach out to us at info@xrmforyou.com

2 thoughts on “Migrate document templates across environments in Dynamics 365”

  1. Thanks for the insight, thats really interesting.

    This is a real oversight by MS, since if you use the action called SetWordTemplate in a workflow and subsequently move the workflow to a new instance (even though you have already moved the template using the XrmToolbox utility as mentioned – a great tool 🙂 ), you will find that the workflow always remains in Draft state as it does not automatically pick up the template. What is required is to open the workflow, open the properties of SetWordTemplate action and then it automatically picks it up (no need to manually search for it). Save and activate. This is a real pain in DevOps pipeline where you want to remove all human interaction as you move solutions down the pipeline.

    Any ideas of how to resolve this?

    1. Hi Hameed,
      Thanks for reading my blog and really sorry for replying late.
      The answer to this is unfortunately no. And mostly this does not happen only for word template but also all scenarios which use a fixed lookup value in the conditions.

      The reason here is that the word template created in the source and the target are created with different GUID’s. Hence when the workflow moved to other environment, it could not find any word template with the same id and hence the issue.


Leave a Reply