For Example: Creating an Account and Contact in the same set inside a flow. If the creation of contact failed, rollback the creation of account also (actually it got succeeded).
For this kinda scenario, Dataverse connector had a special action which is 'Perform a changeset request'. The changeset request really means of sending multiple requests in a single transaction. We can add other Dataverse actions instead of fields inside this action, it supports three actions such as add, update and delete. The operations inside the changeset request are called atomic, because the whole transaction gets rollbacked if any of the action inside the request is failed.
In this article, I have demonstrated how to use perform changeset request action inside a Power Automate Flow.
- To create a flow, go to make.powerapps.com 🡲 Solutions 🡲 +New 🡲 Automation 🡲 Cloud Flow 🡲 Instant.
- A prompt opens for selecting the name of the flow and trigger. Give a name and choose manually trigger a flow, then click Create.
- As it is an Instant flow, it came up with the respective trigger which we selected in earlier steps. Click on Add an action and select Dataverse. It will show many actions which belongs to Dataverse.
- In the listed actions, select Perform a changeset request, and it will transform into a scope like action as in the below image.
- Click on the Add an action inside the action and select add a new row. Select table name as accounts and add the necessary fields.
- Add the another add a new row action inside the changeset and set the table name as contacts and fill those necessary fields.
- Save the flow and Click on Run
- The flow ran successfully, and the result is in the below image.
- For the demonstration purpose, I did a small mistake in the creation of contact to make the flow fail.
- Have you noticed that in the above image, the creation of contact failed as expected. But it also rollbacks the creation of account too. Because they are inside the changeset request.
- As they are in a single transaction, it rollbacks the whole transaction.