Send Notification Email on Business Process Stage change :No code Development

We can go to Workflow screen and create a Workflow (I am using example of Opportunity Sales Process and stages which come with CRM 2013 Online trial)

We will first go to Settings->Process->New


Click on save . Now we start configuring the steps. We will configure the workflow for Record fields change and Click on Select:


Select the following field(As I am sending notification when record is moved to close stage)


Note: You can also configure notification when user switches Process if you Select Process in the above selection instead of stage.

Now, we will click ok and start configuring steps:

We will click on Add Step and Pick Check condition:


Click on Condition and fill the fields like suggested in the below screenshot:


Note: Please mention stage name in CAPS , else it will not work.

Now, Please click Save and close, and select a step for when condition is true. In our case, I will send a notification email to creator of opportunity, hence will pick the step for Send Email:


You can now click on Set Properties and set properties as mentioned below:


Click on Save and Close here and on workflow and Activate workflow:


Note: In case you want to send notification synchronous, you can convert this workflow to Real time workflow.

Now lets try it, Once i move stage of Opportunity to Close, Email is created for me!


Hope it helps!

Change Business Process Flow using JavaScript

Out of box Business Process Flows in CRM 2013 will only move in one direction , i.e. from first stage to second till last. But , real world scenarios are different. We want to create Business Process flows with conditional formatting. From one business process to another based on some condition . I can also move to some third process on some other condition. So, I am taking an example in JavaScript in which based on an option set We will be changing Process flow.First we need to get various stage Guids out from CRM . For which, the following code will list out all the Process Id and Stage Id for given business process:

var service = (IOrganizationService)proxy;
                  QueryExpression query = new QueryExpression
                    EntityName = “workflow”,
                    ColumnSet = new ColumnSet(true)
                 Console.WriteLine(“Please enter the Process Name: “);
                 var processName = Console.ReadLine();
                 query.Criteria.Conditions.Add(new ConditionExpression(“name”, ConditionOperator.Equal, processName));
                EntityCollection response = service.RetrieveMultiple(query);
                QueryExpression query1 = new QueryExpression
                    EntityName = “processstage”,
                    ColumnSet = new ColumnSet(true)

                query1.Criteria.Conditions.Add(new ConditionExpression(“processid”, ConditionOperator.Equal, response.Entities[0].Id));
                EntityCollection response1 = service.RetrieveMultiple(query1);
                Console.WriteLine(“Process Name: ” + processName);
                Console.WriteLine(“Process GUID: ” + response.Entities[0].Id);
                foreach (Entity processStage in response1.Entities)
                    Console.WriteLine(processStage.Attributes[“stagename”] + ” : ” + processStage.Attributes[“processstageid”].ToString());

If you paste this code to a console application it is going to give you output like this:

Process Name: Opportunity Sales Process 1
Process GUID: a013aa17-3d9e-4bfa-b7f7-72a10817d1c2
close : 0e6bbc59-345c-4cce-8bd0-c63d42b79e34
qualify : 155f3ba4-c9c3-43e4-855d-df97c0bc12ef
propose : 5721bc3b-d2fc-42be-ae37-f332ab3f2eb8
develop : 22e8f4ea-9e9a-4ba3-8c2f-ff15026d7d6f

Now the thing to note here is you need to maintain processid, stageid combination , else CRM will not map the process correctly. In this case I am going to move to Propose stage in Opportunity Sales Process 1 . What you got to be careful is all validations (required fields of previous stages are filled in already by the user. Out of box, CRM would have done it for you but now as you are changing it on the fly, you need to be extra careful here)

On opportunity form I have added an Option set having text option set same as Process Name and values as 1,2 for Process Stage selection. Please refer image below:


Following onchange function in JavaScript for Opportunity Process Selection option set will take care of the rest:

function onchange() {

    var selectedProcess = Xrm.Page.getAttribute(“new_processselection”);
    var selectedProcessValue = selectedProcess.getValue();
    if (selectedProcessValue == 2) {
        //Set Guid for Opportunity Sales Prcoess 1


        //Set Guid for Opportunity Sales Prcoess 1 Stage Propose

        //Call Entity save;

        //Call window refresh

Hope it helps!

Check this out

Trying to Learn Dynamics CRM: Download!

Learn Dynamics CRM App on Google Play store