Welcome to our blog where will be sharing tip, tricks and detailed walk-throughs covering all areas of Dynamics 365 but primarily focused on the Field Service and Project Service Apps, Scheduling and integration using Microsoft Flow and the Common Data Service (CDS). We hope you find the blog posts useful and please feel free to comment if you would like us to elaborate on any particular area. 

How to call "SetWordTemplate" action from a Plugin

Today I needed to be able to call the Microsoft action "SetWordTemplate" from a Plugin and encountered the following error:

After a quick "google" I found that I was not the only one who had tried a similar approach and ran up against the same problem. Unfortunately neither of the suggested solutions would not have helped in my case as one involved calling the action from the client via JavaScript, when I needed it to be automated from the server side, and the other involved calling the "SetWordTemplate" action from a Workflow, a technique I was already aware of but of no use in this case as the target entity and document template needed to be set dynamically at execution time by a combination of workflows and custom actions.

Frustrated, I was starting to think I may have to resort to an Azure Function or similar if I wanted to achieve this functionality but on a hunch thought I tried one last potential work-around and hey presto, it worked!

The answer lies in using the ExecuteMultiple request to run the "SetWordTemplate" action in the Plugin rather than executing it directly.

Doesn't work :(

Does Work :)

About an hour after figuring this out, someone else in our team ran up against the exact same issue, so it has already proved to be a very valuable hunch!

Hope this helps someone with the same issue.

149 views0 comments