Streamline your business process flow in Dynamics CRM 2016

By | February 23, 2016

Introduction:

Since the release of Microsoft Dynamics CRM 2013, it had become essential to set business process flow for several professionals in the organization. The main aim was to guide people till the desired outcome through a set of well-defined steps. Irrespective of the entity, the CRM user experience has been streamlined for arriving at a firm conclusion.

In Microsoft Dynamics CRM 2015 creating a record (e.g. lead) through a program from another system and setting the default business process flow is not an easy task.  Now it becomes easier with Microsoft Dynamic CRM 2016 through a new request namely ‘SetProcessRequest’. This is in added to the Action added to the OOB Workflow Designer to be able to set the business process for a record. This has been explained in the earlier blog.

In order to set the Business Process flow, two required parameters need to be passed to the request.

  • New Process (process name): It is a type of Entity Reference. We need to pass the process guid.
  • Target: This Parameter is also a type of Entity Reference. We need to pass the guid and logical name of entity for which we are setting the Business Process Flow.

Let us review this with a sample code.

//Function to create lead record 
public Guid CreateLead(ErrorHandling errorHandler)
{
       //declare Variables 
       string functionName = "CreateLead";
       Guid recordId = new Guid();
       try
       {
           //Create Entity Object
           Entity objLead = new Entity("lead");

           //setProcess properties value
           objLead.Attributes["subject"] = "Inquiry about IPhone6";
           objLead.Attributes["firstname"] = "Peter";
           objLead.Attributes["lastname"] = "Parker";

           //execute Create Request
           recordId = _service.Create(objLead);
       }
       catch (Exception error)
       {

           //throw exception
           errorHandler.ErrorLog(functionName + " This Error occurred " + error.Message);
       }
            //return newly created GUID
            return recordId;
}
The above code contains the method to create a lead records. The method will return the GUID of new record. 
//Function to set Business Process Flow 
public void SetBPF()
{
     //declare variables 
     string functionName = "SetBPF";
     ErrorHandling errorHandler = new ErrorHandling();
     try
     {
           //call Create Lead function
           Guid RecordId = CreateLead(errorHandler);

           //create an object of setprocess request
           SetProcessRequest setProcess = new SetProcessRequest()
           {
                //set process entity refrence 
                NewProcess=new EntityReference("workflow",new Guid("D1090355-279E-432C-872F-14414E3AFCC0")),
                    
               //set target entity refrence 
               Target = new EntityReference("lead", RecordId)
                    
           };
                
           //Execute Set Process request 
          _service.Execute(setProcess);
      }
      catch (Exception error)
      {
           //throw exception
           errorHandler.ErrorLog(functionName + " This Error occurred " + error.Message);
      }
}

The above function is used to call the Create Lead Function and get the GUID for the new record. Later, GUID is passed as a parameter to SetProcessRequest.

After the request has been executed, you can observe that the business process flow is set as shown in the screenshot below. Business Process flow in CRM 2016

One shortcoming though is that it does not allow us to specify a particular stage in the process flow that we need the record to be set in. One of the reasons could be that the business process flow could span across entities and it wouldn’t want discrepancies creeping in with records set to stages in the process flow that are not legit.

Conclusion:

Once the business process flow has been set, you could save time and reduce the effort of training your workforce and increase the chances of users adopting to the existing system. Your company can achieve better results if process flows are configured to support the commonly used sales methodologies.

You may also like to see – User Adoption Metrics that matter in your Dynamics CRM.