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
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.

Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

PA Survey Carousel Image.png

We want to hear from you!

If you are a small business ISV/Reseller, share your thoughts with our research team.

Users online (1,091)