Using Document Generation with SetWordTemplate Action in Workflow in Dynamics 365

The process of generating documents (Word or Excel) is made easy using One Click Document Generation released from Dynamics CRM 2016. And you want to make it even easier by implementing automation with SetWordTemplate action in Workflow. And you may encounter some errors while working with. I’ll show you how to resolve them in this post.

For example, I need to generate a Student profile Word document after a student record is created. I’ll create a workflow and add SetWordTemplate action step.

workflow

The SetWordTemplate action will generate a document regarding a record from a template and attach it to a Note. It needs two parameters:

  • A Word Template
  • A Target record

For steps to setup Word Template, just follow the instruction from: https://docs.microsoft.com/en-us/dynamics365/customer-engagement/admin/using-word-templates-dynamics-365

For Target, you will want to input the current record. But you may find out that you can’t select the current student record to insert. The trick is you need to enable “Business process flows” option in the entity configuration. Then go back to the Action, and now you can insert the student record to Target.

BPFsettarget

When you run the workflow you may encounter the below error:

noteerror

System.Web.HttpUnhandledException (0x80004005): Exception of type ‘System.Web.HttpUnhandledException’ was thrown. —> Microsoft.Crm.CrmException: Creating Entity with an invalid parent. Entity: Annotation, ReferencingAttribute:objectid

This is because it’s trying to create a note and attach the document, but the “Notes” option is not enabled. So go ahead to the entity configuration and enable it.

That’s it. Hope it helps!

3 thoughts on “Using Document Generation with SetWordTemplate Action in Workflow in Dynamics 365

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s