cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Leejoh_Mathew
Level: Powered On

Extract Text from Body of Previous action on failure

Hello All,

 

I am trying to workout a flow which archvies a file and subsequently take some action like creating a new template and sending email to end users.  The archining is scheduled to run at a specfic day/time of the week. All is working good, however there are instances where the archiving action happens when someone has the file opened in edit mode. This is a excel file in shared mode. Obvisouly the delete file action would fail as the file is locked.

 

There are 2 queries I have

 

1. Is there a way to force delete the file even if someone has it open ( I think that is not a possibility)

2. Becasue we will have an error and the workfail will fail, wanted some way to send an email to the end user who has it locked.

 

The message section in the error body from the "delete file" action below has the details of the email ID of the user who has the file locked. So the email needs to go to this ID along with the error message. Not the complete error body.  It might be straight forwrad but am not very technical to get into the nitty gritty. To be clear, I am able to get the entire body into an email but want to limit that to just the actual message.

 

{

  "status": 423,

  "message": "The file \"https://YYYYYY.sharepoint.com/sites/DeliveryTeam/Shared Documents/Test/New EAMD Reporting-WSR Current Week .xlsx\" is locked for shared use by someone@yyy.com.\r\nclientRequestId: 74dc39b5-350d-4107-9173-51acb98a1651",

  "source": "https://yyyyy.sharepoint.com/sites/DeliveryTeam/_api/web/GetFolderByServerRelativePath(decodedUrl=@p...'",

  "errors": [

    "-2147018894",

    "Microsoft.SharePoint.SPException"

  ]

}

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: Extract Text from Body of Previous action on failure

Hi @Leejoh_Mathew,

 

Do you want to extract the email address from the message section of Body content?

I have made a test on my side and please take a try with the following workaround:

  • Choose a proper trigger, here I use Flow Button trigger.
  • Add “Delete file” action, specify Site Address and File Identifier.
  • Add a “Scope” action, configure “Configure run after” option, within “Scope” should run after panel, select “has failed” and then click “Done”:7.JPG

     

  • Within “Scope” action, add a “Compose” action, Inputs set to following formula:
indexOf(string(body('Delete_file')),'by')

Add a “Compose 2” action, Inputs set to following formula:

indexOf(string(body('Delete_file')),'.\r\nclientRequestId')

Add a “Compose 3” action, Inputs set to following formula:

sub(outputs('Compose_2'),add(outputs('Compose'),3))

Add a “Compose 4” action, Inputs set to following formula:

substring(string(body('Delete_file')),add(outputs('Compose'),3),outputs('Compose_3')) 

Add a “Send an email” action, To field set to output of “Compose 4 ” action.

 

Image reference:8.JPG

The flow works successfully as below:9.JPG

 

Best regards,

Kris

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
3 REPLIES 3
Community Support Team
Community Support Team

Re: Extract Text from Body of Previous action on failure

Hi @Leejoh_Mathew,

 

Do you want to extract the email address from the message section of Body content?

I have made a test on my side and please take a try with the following workaround:

  • Choose a proper trigger, here I use Flow Button trigger.
  • Add “Delete file” action, specify Site Address and File Identifier.
  • Add a “Scope” action, configure “Configure run after” option, within “Scope” should run after panel, select “has failed” and then click “Done”:7.JPG

     

  • Within “Scope” action, add a “Compose” action, Inputs set to following formula:
indexOf(string(body('Delete_file')),'by')

Add a “Compose 2” action, Inputs set to following formula:

indexOf(string(body('Delete_file')),'.\r\nclientRequestId')

Add a “Compose 3” action, Inputs set to following formula:

sub(outputs('Compose_2'),add(outputs('Compose'),3))

Add a “Compose 4” action, Inputs set to following formula:

substring(string(body('Delete_file')),add(outputs('Compose'),3),outputs('Compose_3')) 

Add a “Send an email” action, To field set to output of “Compose 4 ” action.

 

Image reference:8.JPG

The flow works successfully as below:9.JPG

 

Best regards,

Kris

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Leejoh_Mathew
Level: Powered On

Re: Extract Text from Body of Previous action on failure

worked exactly as needed.

 

Thanks for your help @v-xida-msft

Highlighted
Sammwise
Level: Powered On

Re: Extract Text from Body of Previous action on failure

Kris - (@v-xida-msft)

 

You're very helpful on a number of posts I have been researching. The functions you're using to manipulate strings and outputs from actions...is there a good reference somewhere to review them? I understand them in the context you use them, but would love to look at a list to be less reliant on searching through posts, heh.

 

Thank you in advance!

 

Sam

Helpful resources

Announcements
firstImage

Microsoft Business Applications Virtual Launch Event

Watch the event on demand for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 Release Wave 2 Plan

Power Platform 2019 Release Wave 2 Plan

Features releasing from October 2019 through March 2020.

thirdimage

Flow Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Flow Community Video Gallery!

Users Online
Currently online: 446 members 4,628 guests
Please welcome our newest community members: