Skip to main content

Notifications

Announcements

No record found.

Customer experience | Sales, Customer Insights,...
Unanswered

Use code to batch update word document templates in D365

Posted on by 125

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
    a2z 125 on at
    RE: Use code to batch update word document templates in D365

    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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans