Introduction
In certain scenarios, we must bundle multiple operations together so that all should pass or fail, in any case if one of the operations fails then all the other operations gets rollbacked to make atomic operations. To achieve this functionality in Power Automate we can use ChangeSet Request Action, as a business scenario operations on Contact and Task tables were considered.
Step 1
Login to the required Power Apps environment using URL make.powerapps.com by providing username and password and clicking on Flows on the left-hand side as shown in the below figure.
Step 2
After Step 1, Click on New Flow and select automated cloud flow and provide the trigger as When a row is added, modified or deleted, and click on Create as shown in the below figure.
Step 3
After Step 2, name the flow as ChangeSet Request and on trigger When a row is added, modified or deleted provide the following inputs
Change Type : Modified
Table name: Contacts
Scope : Organization
as shown in the below figure.
Step 4
After Step 3, add an action and select Dataverse and select an Action Create a new record and name it as Create a Task Record and provide the following inputs
Table name : Tasks
Subject : Contact - triggerOutputs()?['body/firstname'] details changed - Task 1 - utcNow()
as shown in the below figure.
Step 5
After Step 4, add an action and select Dataverse and select an Action Perform a changeset request and name it as Perform a changeset request and inside this action select an action under Dataverse and Update a record action and name it as Update a Task record with wrong id and provide the following inputs
Table name : Tasks
Row ID : 25ede65f-c201-466f-af29-380d369f90ea
And take another action by selecting Dataverse and Update a record action and name it as Update Contact Details for selected record and provide the following inputs
Table name : Contacts
Row Id : triggerOutputs()?['body/@odata.id']
Description : Task 2 - Failed
as shown in the below figure.
Step 6
After Step 5, save and manually run the flow and open any contact record and do updates and click on save and close as shown in the below figure
Step 7:
After Step 6, go and observe the flow as shown in the below figure
Step 8:
After Step 7, go to same contact entity and observe that description was not updated because of failure of update a task record with wrong id as shown in the below figure
Note:
- Make sure to save and run the flow whenever you try expressions.
- Microsoft documentation found here
Conclusion
In this way, we can use change set action in power automate to achieve atomic operations.