cancel
Showing results for 
Search instead for 
Did you mean: 

Update Business Process Flow stages using Power Automate

Recently, I have come across a requirement to update business process stage automatically on update of status field.

The status field is updated by external users via PowerApps Portal.

We can achieve this many ways . Writing custom code can be an option . But I thought of using Power Automate. ( Microsoft Flow is renamed to Power Automate ).

Quick note on Business Process Flow:

The method of retrieving and updating BPF fields within the record is deprecated. Read more on https://docs.microsoft.com/en-us/power-platform/important-changes-coming#legacy-process-related-attr...

 

legacy.png

 

 

 

 

 

 

The supported way is is to reference fields in the BPF entity that would have been created when your BPF was created. 

Read more on https://docs.microsoft.com/en-us/dynamics365/customerengagement/on-premises/developer/model-business...

Alright, lets understand the logic before configuring flow.

Here is my logic . Status value and their corresponding stage.

image.png

 

 

 

 

 

 

 

 

 

 

 

Trigger :

The trigger is when the status is updated.

image.png

 

 

 

 

 

 

 

 

 

 

 

 

Initialize variable to store Stage Ids and Status values:

image.png

 

Retrieve Business Process Flow instance record :

List Record action is used to retrieve BPF instance record associated with work order record.

Filter query is for the purpose of returning BPF instance record associated to work order.

image.png

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Compose actions to retrieve BPF instance Id and Process Id:

 

image.png

 

 

 

 

Here are the expressions to retrieve BPF instance id and Process Id from the above List Record action.

BPF instance record id : first(body(‘Get_Work_Order_BPF_record’)?[‘value’]).businessprocessflowinstanceid

Process Id : first(body(‘Get_Work_Order_BPF_record’)?[‘value’])._processid_value

 

Get BPF Stages Ids dynamically :

image.png

 

 

 

 

 

 

 

 

 

 

 

 

 

 

We need to pass BPF instance record in the filter query.

 

Store BPF Stage Ids in Variables :

Apply for Each action is used to loop through the result got from above list record action and Switch Control is used to store stage ids in variables based on stage name.

image.png

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Update BPF Stage based on Status value :

Here again, Switch Control is used to update stage according to status value.

And Update record action is used to update BPF instance record with stage id.

image.png

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Traversed path :

The Traversed Path is a field as mentioned earlier that represents the life cycle of the business process flow as it contains the stage IDs the Business Process Flow as gone through. The Traversed Path field value needs to be updated to include the stage ID of the current active stage it will be moved to. This is the Review stage.To include the stage ID in the Traversed Path field the concat function is used in an expression.

For example, if BPF is moving from first stage to second stage , the expression should like below

concat(firststageid, ‘,’ ,secondstageid)

 

Conclusion :

If we follow the above steps , the total flow should like this.

image.png

Thank you for reading . Hope it helps.

Blog link : https://powerofpowerplatform.com/update-business-process-flow-stages-using-power-automate-microsoft-...

Meet Our Blog Authors
  • Experienced Consultant with a demonstrated history of working in the information technology and services industry. Skilled in Office 365, Azure, SharePoint Online, PowerShell, Nintex, K2, SharePoint Designer workflow automation, PowerApps, Microsoft Flow, PowerShell, Active Directory, Operating Systems, Networking, and JavaScript. Strong consulting professional with a Bachelor of Engineering (B.E.) focused in Information Technology from Mumbai University.
  • Encodian Owner / Founder - Ex Microsoft Consulting Services - Architect / Developer - 20 years in SharePoint - PowerPlatform Fan
  • Cambridge UK Power Platform User Group Leader, Technical evangelist and speaker. Always says yes to coffee! #LetsGetCoffee
  • Passionate #Programmer #SharePoint #SPFx #Office365 #MSFlow | C-sharpCorner MVP | SharePoint StackOverflow, Github, PnP contributor
  • I am building business processes and applications that are easy for users' to stick to, so they can follow and understand them. In overall I transform processes to be more reliable and effortless. I am a proud co-organizer of SharePoint Saturday Warsaw and active community member, blogger and international speaker.