cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Leejoh_Mathew
Frequent Visitor

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
v-xida-msft
Community Support
Community Support

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.

View solution in original post

3 REPLIES 3
v-xida-msft
Community Support
Community Support

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.

worked exactly as needed.

 

Thanks for your help @v-xida-msft

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
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

May UG Leader Call Carousel 768x460.png

June User Group Leader Call

Join us on June 28 for our monthly User Group leader call!

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

Power Automate Designer Feedback_carousel.jpg

Help make Flow Design easier

Are you new to designing flows? What is your biggest struggle with Power Automate Designer? Help us make it more user friendly!

Users online (1,250)