Send Workflow Email from Executing User Dynamics CRM 2011

Paul Nieuwelaar, 25 April 2012

In Dynamics CRM 2011, we can create workflows that get triggered on create/update of records within our system. A common example is where a new Lead comes in, and a workflow is triggered (on create) which emails the Lead, sent from the Lead Owner.

This kind of scenario is fine, as it makes sense for the email to come from the Owner of the Lead, since they are the User dealing with the prospect.

 Send Workflow Email from Executing User Dynamics CRM 2011

In another scenario though, where you want to send an email to a group of Leads, you would require the use of an on-demand workflow. In this case you may not want the emails coming from the Owner, since you are executing the workflow you want the emails to come from you.

To achieve this is actually quite simple. If all you require is for the on-demand emails to be sent from you, the user executing the workflow, then all you need to do is leave the ‘From’ field blank in the workflow email. When the workflow is triggered, the ‘From’ field will automatically be set to the user executing the workflow (also known as the System Job ‘Owner’).

 Send Workflow Email from Executing User Dynamics CRM 2011

Because you run the workflow on-demand, you are set as the Job Owner, and therefore the emails are sent from you.

 Send Workflow Email from Executing User Dynamics CRM 2011

If you need access to other details of the executing user (for example the users full name), this will not be available. However you can get around this by updating a hidden radio button in the workflow before sending the email. This will set the executing user as the ‘Modified By’, which can then be used in the emails and other workflow steps to get the dynamic values from the user.

Send Workflow Email from Executing User Dynamics CRM 2011

Send Workflow Email from Executing User Dynamics CRM 2011

For dynamically triggered workflows (run on create/update), the Job Owner will instead be set to the owner of the Process, and so this will not work so well leaving the email ‘From’ field blank. However by using the ‘Modified By’ user in this case you still have access to the user that triggered the workflow, since an update or create event will have triggered the workflow.

If you are planning to have a workflow that runs both dynamically and on-demand, then you will run into some problems. By leaving the ‘From’ field blank for the on-demand emails, it means the dynamically triggered emails will send from the process owner. Even if you use the hidden field update method, when the workflow is run dynamically the Modified By will be set to the process owner when the radio button is updated. In this case, consider splitting it into two workflows or two child workflows to allow for the correct option to be applied for each scenario.

In summary, the following rules should be applied when sending workflow email from the executing user:

Create/Update (dynamically triggered): Set the ‘From’ field to the ‘Modified By’ User.

On-demand: Leave the ‘From’ field Blank, it will automatically send from the user executing the on-demand workflow. Otherwise, update a hidden radio button before sending the email, so that the ‘Modified By’ user can be used in the email.

Remember that these two methods do not work well together in the same workflow, as dynamically triggered workflows will use the owner of the Process, rather than the Executing User.