Dynamics CRM 365 : Downloading a Word Document Template via a Button on the Ribbon

When you click the templates flyout, it's dynamically populated through an invocation of /AppWebServices/DocumentTemplate.asmx, which returns the XML for the menu.

The flyout for Word Templates in the Incident home page grid looks like this:

<Menu Id="incident|NoRelationship|HomePageGrid|Mscrm.HomepageGrid.incident.WordTemplates.Menu">
    <MenuSection Id="incident|NoRelationship|HomePageGrid|Mscrm.HomepageGrid.incident.WordTemplates.Menu.CreateTemplates" Title="Create Word Template" Sequence="10" DisplayMode="Menu16">
        <Controls Id="incident|NoRelationship|HomePageGrid|Mscrm.HomepageGrid.incident.WordTemplates.Menu.CreateTemplates.Controls">
            <Button Id="incident|NoRelationship|HomePageGrid|Mscrm.HomepageGrid.incident.WordTemplates.Menu.CreateTemplates.Controls.00000000-0000-0000-0000-000000000000" Command="incident|NoRelationship|HomePageGrid|Mscrm.WordTemplate.CreateWordTemplate.Grid" Sequence="10" ToolTipDescription="Create Word Template" Alt="Create Word Template" LabelText="Create Word Template" />
        </Controls>
    </MenuSection>
    <MenuSection Id="incident|NoRelationship|HomePageGrid|Mscrm.HomepageGrid.incident.WordTemplates.Menu.WordTemplates" Title="Word Templates" Sequence="20" DisplayMode="Menu16">
        <Controls Id="incident|NoRelationship|HomePageGrid|Mscrm.HomepageGrid.incident.WordTemplates.Menu.WordTemplates.Controls">
            <Button Id="incident|NoRelationship|HomePageGrid|Mscrm.HomepageGrid.incident.WordTemplates.Menu.WordTemplates.Controls.9b77c5b0-1033-4741-a01c-afdbdb1c3f22" Command="incident|NoRelationship|HomePageGrid|Mscrm.WordTemplate.TemplatesMenu.Grid" Sequence="10" ToolTipDescription="Case Summary" Alt="Case Summary" LabelText="Case Summary" />
        </Controls>
    </MenuSection>
</Menu>

I don't have the means to try it out at the moment, but I'd try and "copy" the last <Button>:

<Button Id="incident|NoRelationship|HomePageGrid|Mscrm.HomepageGrid.incident.WordTemplates.Menu.WordTemplates.Controls.9b77c5b0-1033-4741-a01c-afdbdb1c3f22" Command="incident|NoRelationship|HomePageGrid|Mscrm.WordTemplate.TemplatesMenu.Grid" Sequence="10" ToolTipDescription="Case Summary" Alt="Case Summary" LabelText="Case Summary" />

It's possible to do this using only supported features of CRM (of course I'm sure it's also possible to do using unsupported javascript, but I don't have time currently to investigate this). The steps that you should take to achieve the functionality you want:

  1. Create new process of type Action, bound to entity that you want to create a template for (the reason why I suggest Action here, is that it can be easily invoked using JavaScript and CRM WebAPI)
  2. In this Action add single step - invoke an Action and choose built-in action "SetWordTemplate"
  3. Set Properties of this action - choose the template that you need and dynamically set the target to current entity (using Dynamic Values assistant) If you never used this action - it simply creates a given word template and adds it as an annotation to your entity
  4. Now you need to write logic inside your button (I'm assuming you know how to add a button using Ribbon Workbench or whatever)
  5. Call your action using WebAPI
  6. Find annotation that was just created for your entity with the attached document
  7. Download the attachment (you can show some prompt for the user or simply force the download the file, user will have to save it)
  8. Delete the annotation

Maybe not a one-liner, but keeps you in the supported zone...