Posts Tagged ‘Workflow’

Dynamics workflow – Unable to set Email ‘Regarding’ field

December 3, 2019 Leave a comment

Other day, while working on a straight forward ‘Send Email’ using a ‘Workflow’, I could not set the ‘Regarding’ field on ‘Email’ form.


  • Create a new custom entity ‘Transaction’.
  • Send an Email when a new ‘Transaction’ record gets created.

So, I created a new workflow on ‘Transaction’ entity and added ‘Send Email’ step.


On the ‘Email’ configuration screen, all I could see was a blank ‘Look for:’ field.


Reason & Fix:

  • ‘Activities’ option was not enabled on the ‘Transaction’ entity.


  • Enable ‘Activities’ and publish.
  • Go to the workflow and I got the Entity Reference in ‘Look for:’ field.


Its one of those days where we struggle for trivial problems 🙂


Categories: CRM Tags: ,

‘Wait Condition’ in Workflow Explained

February 19, 2017 1 comment

I was asked by one of my blog followers to explain ‘Wait Condition’ in Workflow.


To explain this better, I took a small scenario

  • Send an Email to Opportunity Owner, whenever an Account has been assigned to the Opportunity

Configuring Work Flow :

  • Create a workflow on Opportunity which triggers when ‘Record is created’
  • Add a “Wait Condition” to check, if Account got assigned to Opportunity (I.e., Opportunity. Account ‘Contains Data’)


  • Create an Email Activity, if ‘Wait Condition’ met


  • Save and Activate Workflow

Test the Workflow

  • Create new Opportunity


  • Check the Waiting job in ‘System Jobs’
    • Since we have the Wait condition set in our workflow, the Job will wait until the condition met


  • Associate ‘Account’ to the ‘Opportunity’


  • Check the Waiting Job now and it should have completed.


  • New Email created in system as the follow up action

Key Points to consider before using Wait Conditions:

While the ‘Wait conditions’ are useful in case of the timer related tasks which will be achieved with no coding, excessive use of wait conditions has a downside.

  • Performance:
    • Each waiting workflow instance carries performance overhead. The more waiting workflow you have, the more server resources will be consumed by the Asynchronous Processing Service.
    • If you change the logic in your workflow and republish (like update the text of the email sent to your client), it does not change waiting workflow instances. For example, if you change the renewal email frequency to 15 days rather than 30 days, any workflow instances that are waiting will not be updated.



Categories: CRM Tags: ,

How to debug XAML Workflows when invoked remotely

Assume you have a XAML workflow created using WF designer and you trigger this workflow from a console application which is in another server.

Below are the steps to debug

  • Install “Workflow Manager Tools”
  • After installation you can find a folder under “C:\Program Files (x86)\Workflow Manager Tools\1.0”
  • Open “Microsoft.Workflow.TestServiceHost.exe.config” using Visual Studio
  • Make sure all ‘connectionStrings’ pointing to proper Data base.
  • Open “Command Prompt” as Administrator.
  • Point to “C:\Program Files (x86)\Workflow Manager Tools\1.0”, Run the “Microsoft.Workflow.TestServiceHost.exe”
WF Test Service Host

WF Test Service Host

  • Keep the Command Prompt open (i.e., Minimize it)
  • Open the workflow you want debug using Visual Studio
  • Attach below Processes
Attach Processes

Attach Processes

  • Put a break point on the Workflow file
Break Point on WF file

Break Point on WF file

  • Invoke the Workflow from console and you get the breakpoint hit on Workflow.


Categories: Misc Tags: , ,

Execute the workflow from JScript In CRM

October 2, 2011 1 comment


We can run the CRM workflows from JScript, if we know the GUID of the workflow. Below are the execution steps.

Steps :-

  • Get the GUID of workflow from name using OData Service  (i.e., Using GetWorkflowIDByName(wfName) function )
  • Execute the Workflow using the GUID (i.e., Using TriggerWorkflow(workflowGuid) function)

Below are the JScript functions mentioned in above steps.

function GetWorkflowIDByName(wfName) {

var serverUrl = Xrm.Page.context.getServerUrl();

//Prepare ODATA query to fetch WF GUID by WF Name

var odataSelect = serverUrl + “/xrmservices/2011/OrganizationData.svc/WorkflowSet?$select=WorkflowId&$filter=ActiveWorkflowId/Id ne null and Name eq ‘” + wfName + “‘”;



contentType:“application/json; charset=utf-8”,


url: odataSelect,

beforeSend:function (XMLHttpRequest) { XMLHttpRequest.setRequestHeader(“Accept”, “application/json”); },

success:function(data, textStatus, XmlHttpRequest) {



error:function (XmlHttpRequest, textStatus, errorThrown) { alert(‘OData Select Failed: ‘+ odataSelect); }



function RetrieveWorkflow(Entity) {

var objFilteredWF = null;

objFilteredWF = Entity;

wfID =null;

//Get the WF GUID from OData result set

if (objFilteredWF != null && objFilteredWF.results != null && objFilteredWF.results.length != 0 && objFilteredWF.results[0].WorkflowId != null) {

wfID = objFilteredWF.results[0].WorkflowId;




//Trigger WF using WorkflowGUID

function TriggerWorkflow(workflowGuid) {


var soapBody = “<soap:Body>”+” <Execute xmlns=’’>&#8221;

+ ” <Request xsi:type=\’ExecuteWorkflowRequest\’>”

+” <EntityId>” + + “</EntityId>”

+” <WorkflowId>” + workflowGuid + “</WorkflowId>”

+” </Request>”

+” </Execute>”


/*Wrap the Soap Body in a soap:Envelope.*/

var soapXml = “<soap:Envelope “

+” xmlns:soap=’; “

+” xmlns:xsi=’; “

+” xmlns:xsd=’’>&#8221;

+ GenerateAuthenticationHeader()

+soapBody +


/* Create the XMLHTTP object for the execute method.*/

var xmlhttp = new ActiveXObject(“Msxml2.XMLHTTP”);“POST”, “/MSCRMservices/2007/crmservice.asmx”, false);

xmlhttp.setRequestHeader(“Content-Type”, “text/xml; charset=utf-8”);


/* Send the XMLHTTP object. */



catch(e) {