web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Unanswered

Use code to batch update word document templates in D365

(0) ShareShare
ReportReport
Posted on by 129

I am currently investigating using code c# to update the "documenttemplate" entity.

According to MS, these are the "documenttemplate" entity columns that are writeable.

pastedimage1622508297123v1.png

As we will end up with heaps of document templates, we want to be able to batch update the templates rather than import.

In this way, the document template guids remain the same (yes, I do realize there are Xrm tools available to do the import).

Assuming all the document template records are already in the target instance, we simply run this code to batch update this entity per document template.

The issue is with the column called "ClientData".

I can get the Content easily by converting the word document template file to base64 but I have no idea where I can get the ClientData.

Does anyone know where ClientData comes from and how to extract it from the Word document template file?

pastedimage1622508995206v2.png

Thanks

a2z

  • a2z Profile Picture
    129 on at

    I had a look at our document templates that we have uploaded to D365 and I noticed that the ClientData values are all the same.

    I am referring only to word document templates.

     Client Data - encoded

    {"Range":null,"Columns":null,"DisplayConditions":"\u003cDisplayConditions\u003e\u003cEveryone /\u003e\u003c/DisplayConditions\u003e"}


    Decoded (almost):  \u003c = < and \u003e = >

    {"Range":null,"Columns":null,"DisplayConditions":"\u003cDisplayConditions\u003e\u003cEveryone /\u003e\u003c/DisplayConditions\u003e"}

    pastedimage1622540162087v1.png

    The exceptions are those OOTB Excel templates and we don't use Excel templates (whew!).

    So based on this finding, I believe I can safely update the documenttemplate entity record. 

    I am referring to the Content field which contains the Base64 version of the actual document template file.

    If there is a change in our template file, I just need to find the matching template record in the documenttemplate entity and update the Content field.

    If I were to add a new word template, I can safely assume and use the same ClientData as specified above.

    I already have the list of entity types so it would easy to match them with the document template that I need to import by code.

    Well I hope I am correct so please correct me Microsoft if I am wrong.

    It would a lot nicer if MS provided better documentation to explain the documenttemplate entity.

    a2z

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the August Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Syed Aqib Raza Profile Picture

Syed Aqib Raza 125

#2
ParthPatel249 Profile Picture

ParthPatel249 87

#3
11manish Profile Picture

11manish 85 Super User 2026 Season 2

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans