Business Process Flows till CRM 2016
Every record with Business process flow till Microsoft Dynamics 2016 , used to have two attributes specific to them:- Process ID : Process Stage ID.
To set a desired Business Process Flow, on a record based on some input from the Quick Create form in CRM as follows :-
- Let’s say over the “Quick Create” form, we have a Business Stream “O” and Sub Business Stream “Renovation”, the selected value will be available to us in the plugin registered over “Pre-Operation”.
- Based on the value, available to us we need to fetch the GUID of the desired business process flow from the processes entity along with the process id using the retrieve operation in MS CRM
- We can now, set the values of the Process ID and Process Stage ID based upon the retrieved values from the CRM, using the same plugin registered over “Pre-Operation”, and thus when the form will be loaded after creation, it will have the desired business process flow over the same.
Entity.Attributes [ProcessId] = workFlowId
Business Process Flow in Dynamics 365
There has been a change in the architecture of the “Business Process Flow” entity in the Dynamics 365, earlier till 2016 whenever we used to switch the business process flow over a record, then the stage of the switched business process flow used to set to default stage over the entity form.
To overcome the same, in Dynamics 365 the architecture has been changed and now though we switch the business process flow the stage is not set to default.
For the same a new message has been introduced in Dynamics 365 – SetProcessRequest
Contains the data that is needed to set another business process flow instance as the active process instance for the target entity. If there isn't any active business process flow instance for the target entity record and the specified business process flow definition, a new business process flow instance will be created and set as the active instance.
SetProcessRequest setProcessRequest = newSetProcessRequest ()
{
Target = Entity.ToEntityReference (),
NewProcess = entBusinessProcessFlow.ToEntityReference ()
};