Workflow Tip to set Document Type and Category

By | July 30, 2014

Document merging is an important functionality of Sage CRM when it comes to sending newsletters, welcome letters etc. User can do the document merging using workflows.
New Stuff: Control users to create Appointments in Sage CRM
Consider an example where user generates document using Generate Letters workflow rule added on the Case workflow as shown below.

Clicking on above rule, document gets merged and below message will be visible to the users.

Clicking on Continue button, Communication will be created and document will be saved under Documents tab as shown below.

If you click on the File generated, you will see the details.

You can observe Type and Category fields are not set for the merged document.
With little medications in the workflow rule it can be done. Current Generate Letter rule would have Create Merge Document workflow Action set into it. Select the Generate Letters rule and add Execute SQL statement Rule Action on it.
Merged5
1) Copy below query in SQL statement as shown below.
Update Library set Libr_Type = ‘Proposal’, Libr_category=’Sales’
where Libr_LibraryId =
(
select top 1 Libr_libraryId from Library (nolock)
where Libr_CaseId = #Case_CaseId#
order by Libr_LibraryId desc
)
2) Set the Order as 2. (Set order 1 for Mail Merge Document workflow action.)
3) Save the workflow and Activate Workflow.
– Please ensure proper backups are taken before executing the following solutions –
Now, when document gets generated, you will observe, Library Type will be set as Proposal and Category as Sales.
Merged6
You can apply above steps to any entity. However you need to modify update query mentioned in the point 1 as per requirement.