In this post, let us look how we are going to handle the Office
365 SharePoint action errors that occurs on Microsoft Flow platform.
Problem Statement: There is an option to get the user
profile property on Microsoft Flow using SharePoint REST API. We need to handle
if there is any error to this action. Let us see how to handle/catch the error
and send a mail with error details.
Sometime back I have published an
article for updating user display names for items created on SharePoint using Microsoft
Flow. We will use the same concept here, but only we will see how to catch and
send the error details over mail.
The flow to get and update the user profile property is as follows.
- Create a trigger to fire the flow whenever an item is created.
- Create a SharePoint action “Send an HTTP request to
SharePoint”, to get the user profile property details as explained in the
article mentioned above.
- Parse JSON data to get the exact required property (user
display name).
- Update the same item with author name field with the value
retrieved.
Handling Error:
The following steps shows how to configure the flow to handle the error and configuring appropriate send email action.
- Just after the “Send an HTTP request to SharePoint” action,
add a parallel branch with an action.
|
Breaking the existing Flow and Adding Parallel Condition for Error Actions |
- In the parallel branch, add an “Send an
email” action. In the action provide the necessary details like, email address,
subject and body text.
|
Setting Send an email option inputs to send error details |
- From send an email action, click on more option (three dots). Select "Configure run after" option.
|
Clicking configure option for send an email action |
- Configure the action to run once the "send an http request" action fails, as shown below. This is done be selecting has failed check box for the previous action. Click on done once configured.
|
"Configure run after" being set on Email Action to "has failed" for HTTP request action |
- Parallely parse JSON will have configure option set to "is successful".
|
Flow showing two parallel actions. On the left success action and on the right failed action being configured. |
Test the Flow for Error Handling:
To test the error flow, I have made changes in "send an http request" action to fail. I have just added the user claim id without encoding
into the "send an http request" action. This will make the action to fail, since
the user id is not encoded.
Test the flow by going to list and creating an item. After
few movements, come back to the flow and check the status of items.
|
Flow Snapshot showing the error handling and email alert being sent |