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.

View solution in original post

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.

View solution in original post

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

Power Platform Online Conference

Join us for the first ever Power Platform Online Conference!

firstImage

Incoming: New and improved badges!

Look out for new contribution recognition badges coming SOON!

firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

thirdimage

Power Automate Community User Group Member Badge

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

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Power Automate Community Video Gallery!

Users online (4,747)