Getting Responses from called Flows
In the previous parts of this series we have built 1 main flow and two called flows. If a flow calls another flow it shows a success unless the called flow includes a response, even if the called flow fails. In this last post of this series we will add responses to the called flows so that any failures are caught.
This will be done in three stages, firstly adding a success message to be returned and secondly a failed message and finally sending back some data from the called flow. The Break Inheritance flow is triggered from a HTTP call from the main flow. Below is link to a picture of the flow in from the previous post.
Success Response
- Below the last action we need to add a Response action. This action is not obvious to find but in my experience search for Response and scroll down lots. It has a green icon.
- For a success the Status code needs to 200. The codes are a standard list of responses, a full list of the codes and their use can be found at https://httpstatuses.com/The Body can be a message showing what has been completed, later in this post we will look at returning a data structure.
- Test the flow that to check it still works and see the message returned in the Run History and check the run history for a flow that calls this flow.
Failure Response
- Steps 1 to 3 have added a success message, the next step is to add a failure message. Click the + above the Response action and add a parallel branch and add another Response action.
- The Status Code needs to be 400 to show a failure and you can add a suitable message in the Body.
- Click on the ellipsis (…) on the failure response action and select Configure run after. By default an action runs when the previous step is successful. Change the selected options to make this action run when the previous step Fails and click Done. Note: For longer flows or ones with actions that can time out it is worth ticking failed, skipped, and timed out.
- The arrow to the on fail step will change to have a dotted red line.
- Test the flow to make sure it still works. I built a very simple test of a failure by trying to break inheritance on an item on a list that didn’t exist.
Returning Data
- So we now have a success message and a failure message. In this case this is possibly enough but to make this post complete I want to add a structured response with values that could be used in further actions by the calling flow. The schema, which define the data structure, of the response needs to be defined.In the Success Response, click on Use sample payload to generate schema and enter in an example of the data to be returned in JSON format.
- Click Done and the schema will be generated. Now in the Body enter in the response to be sent. You can use returns to lay it out, remember string values will need to be wrapped in quotes.
- Test calling your flow and see the response return.
- Further actions can refer to the response by using an expression. The body function takes the name of the action with spaces replaced by underscores and then in square brackets the name of the item.
Examplebody('HTTP_-_Break_Item_Inheritance')['Action']
Conclusion
In this long post we have made our called flows give back a success or failed message and we’ve added data to give meaning to that response,
“How to manage permissions on a SharePoint List Item using Microsoft Flow! – Series Navigator: