CRM 2016 has the ability to generate documents using Word templates. For workflows there’s a custom action called SetWordTemplate which can be added via Add Step > Perform Action > SetWordTemplate.
Shamira (Sam) Fernando has the answer. The below snippet can be used to generate a document from code and the action attaches the generated document to the target record. The document template needs to be a system template – personal document templates won’t work.
OrganizationRequest req = new OrganizationRequest("SetWordTemplate"); req["Target"] = new EntityReference("account", accountGuid); req["SelectedTemplate"] = new EntityReference("documenttemplate", templateGuid); service.ExecuteCrmOrganizationRequest(req);