The new business process flow designer in Dynamics 365 is lovely! However, I’m not going to talk about that since it’s rightly had lots of love by others already.
For me the biggest change in Dynamics 365 is the fact that running Business Process Flows (BPFs) are now stored as entity records. Instance details are no longer held as fields on the associated record. I first visited this topic back in the CRM2013 days with the introductions of Business Process Flows where I described how to programmatically change the process.
Previously when a BPF was started, all of the state about the position was held on the record it was run on was stored in fields on the record itself:
- Process Id: The ID of the BPF running
- Stage Id: The ID of the BPF step that was active
- Traversed Path: A comma separated string listing the GUIDs of current path of steps taken through the BPF. This is to support BPFs with branching logic.
With the new Dynamics 365 BPFs, each process activated is automatically has an entity created that looks just like any other custom entity. The information about the processes running and any record is now stored as instances of this entity with a N:1 relationship to the parent record and any subsequent related entities. This BPF entity has similar attributes that were stored on the parent entity, but with the following additions:
- Active Stage Id: The ID of the BPF step that is active – replaces the Stage Id attribute.
- Activate Stage Started On: The Date Time that the current step was started on – this allows calculation of the amount of time it has been active for
- State & Status: Each BPF Instance has its own state that allows finishing and abandoning before other BPF are run.
In addition to making migration of data with running BPFs a little easier – this approach has the following advantages:
- You can control access to BPFs using standard entity role privileges
- You can have multiple BPFs running on the same record
- You can see how long the current stage has been active for
- You can Abandon/Finish a BPF
Prior to Dynamics365, you would have controlled which roles could access your BPF using the Business Process Flow Role Check list. In Dynamics 365 when you click the ‘Enable Security Roles’ button your BPF you are presented with a list of Roles that you can open up and define access in the ‘Business Process Flow’ tab:
Multiple BPFs on the same record
Switching BPFs no longer overwrites the previous active step – meaning that you can ‘switch’ back to a previously started BPF and it will carry on from the same place. This means that BPFs can run in parallel on the same record.
- If a user does not have access to the running BPF they will see the next running BPF in the list (that they have access to).
- If the user has no access to any BPF that is active – then no BPF is shown at all.
- If user has read only access to the BPF that is running, then they can see it, but not change the active step.
- When a new record is created, the first BPF that the user has create privileges on is automatically started.
When you use the Switch Process dialog, you can now see if the Business Process Flow is already running, who started it and when it was run.
NOTE: Because the roles reference the BPF entities – you must also include the system generated BPF entities in any solution you intend to export and import into another system.
Active Step timer
Now that we have the ability to store addition data on the running BPF instance, we have the time that the current step was started on. This also means that when switching between processes, we can see the time spent in each step in parallel running BPFs.
Since each BPF has its own state fields, a business process can be marked as Finished – or Abandoned at which point it becomes greyed out and read only.
When you ‘Abandon’ or ‘Finish’ a BPF it is moved into the ‘Archived’ section of the ‘Switch Process’ dialog.
NOTE: You might think that this means that you could then run the BPF a second time, but in-fact it can only have a single instance per BPF – and you must ‘Reactivate’ it to use it again.
- Reactivating an Abandoned BPF will start at the previously active step
- Reactivating a Finished BPF will start it from the beginning again.
Imagine your business has a sales process that requires an approval by a Sales Manager. At a specific step in that sales process you could run a workflow to start a parallel BPF that only the Sales Managers have access to. When they view the record, making the Approval BPF higher in the ordered list of BPFS will mean that they will see the Approval BPF instead of the main Sales Process. They can then advance the steps to ‘Approved’ and mark as Finished. This could then in turn start another Workflow that updates a field on the Opportunity. Using this technique in combination with Field Level Security gives a rather neat solution for custom approval processes.
When I first saw this change I admit I was rather nervous because it was such a big system change. I’ve now done a number of upgrades to Dynamics 365 and the issues I found have all been resolved.
I’m really starting to like the new possibilities that Parallel BPFs brings to Dynamics 365.
Bron: http://www.develop1.net/public/post/Dynamics-365-Business-Process-Flows.aspx @ScottDurow