Tip #691: Extract an existing Word Template from CRM 2016

Tooth ExtractionIn CRM 2016 we have the fantastic Word Templates feature with which users can generate finished documents in just a few clicks. Far easier than the old mail merge options, and no need to have locally installed versions of Word, the Outlook client and so on.

But one annoying limitation of the feature for many is that there is no obvious way to download or export an existing template. So you can’t get the OOB Account Summary report, make a few minor changes and upload it – you have to start from scratch every time. Or if your colleague built a template and uploaded it to UAT then goes on vacation without sharing the original to your shared source area, you can’t upload that to production when the client signs it off.

Sarah “definitely a cat in a previous life (or the next)” Critchley is a regular contributor to CRMUG in the UK, and draws some great infographics to explain various CRM topics, or as a way to collate her notes from other people’s presentations. She wrote an article about how to auto-generate Word templates using a Workflow and the OOB Action SetWordTemplate. Buried in the article is a little nugget of information mentioned almost in passing as a bit of a “gotcha” to avoid if you choose a template for the wrong entity.

Adam “you say gotcha, I say undocumented feature” Vero spotted this and realised the potential: you can download any existing template by creating an on-demand workflow that is (purposefully) badly written. You create a new, on-demand Workflow for any entity except the one the template is for as long as it supports Notes*. Contact would be a good example here. In the Workflow you add a step to perform a SetWordTemplate Action, set the properties and select the Word template you want to export and the current entity record such  as {Contact(Contact)}.

Activate the Workflow, go find a Contact record and run the Workflow against it. The template you selected does not “work” for this entity, so the Note that is created will have the original template attached with all the raw XML content controls you need, instead of a finished document. Simply download this attachment, delete the note, and deactivate your Workflow. Next time you need to do this, simply edit your Workflow to select a different document template, re-activate and run it again.

*you can use the entity the template is for, as long as it has at least one parent entity that supports Notes. So if you have built a Workflow for Contact and later want to use this to extract a template for the Contact entity, just select the template you want and make the target something other than the Contact, such as {Company Name(Contact)}. When you run the workflow, the template will be attached to a Note on the parent Account record (in this example).

All we have to hope now is that Microsoft don’t decide this is a bug that needs fixing in a later version…

5 thoughts on “Tip #691: Extract an existing Word Template from CRM 2016

  1. Karthick says:

    Much needed workaround. Thanks for sharing. I will try this out.

  2. Jason Traxton says:

    Worked perfectly to fix another one of Microsoft’s short-sighted issues.

  3. Ronald Lemmen says:

    Note: The Document Template Manager in XrmToolBox can be used as well to export templates. http://www.xrmtoolbox.com/Plugins.html

  4. Greg Owens says:

    “…if your colleague built a template and uploaded it to UAT then goes on vacation without sharing the original to your shared source area, you can’t upload that to production when the client signs it off..”

    Neither can you do that if:
    1) It’s an Excel Template
    2) It includes attributes from another (custom?) entity

    It seems that if your template spans entities, the FetchXml that underpins the runtime query to populate the template includes aliases for linked entities that *differ for each environment*. This means that even if your UAT and Production environments have the same managed solution, your UAT Excel template will not work if you upload it to Production (if it requires columns from a linked entity).

    “Undocumented feature” indeed. Microsoft support even insist that this is not a supported scenario.

    • Friedhelm Wolf says:

      The reason templates are not usable for different Environments is mostly due to differing object type codes for the same entities. We confirmed that it is possible to replace the object type codes in the word metadata XML Information and thus make it work for other Environments.

Leave a Reply

Your email address will not be published. Required fields are marked *