Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM forum
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

Anton Venter – Community Spotlight

Kudos to our October Community Star of the month!

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Dynamics 365 Community Newsletter - September 2024

Check out the latest community news

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,554 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,588 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans