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

Trying to get error details from a prior scope - outputs('TryScope-LoadLookupDataFromSharePointLists') returns null

Goal:

I want to provide some basic error handling for unexpected conditions, but I don't want have to manually get the output for each action. So I group similar actions into a "TryScope", then run_after_error on a CatchScope.

 

Setup:

Create scope "TryScope-LoadLookupDataFromSharePointLists"

Create scope "CatchScope-LoadLookupDataFromSharepointLIsts", set "should run after  = has failed"

  (See image 1)Try-Catch-Scopes-RunAfterSettings.jpg

 

 

Within the Catchscope I am using: fx:          outputs('TryScope-LoadLookupDataFromSharePointLists')

 
Which I am expecting to get the RAW JSON of any failed action within the TryScope.
 
Problem:
 
When I force an error within the TryScope (I forced the SharePoint view to an invalid name .. thus the working call fails) the Catch Set_ErrorRAW shows a null result.
 
Here is the test run:
Catch on Output of Scope gets NULL.jpg
Now if instead of getting the output of the scope, if I get the output of the specific action, it works, but that means that I have to manually get the raw output, then parse it to see if it was the Action/Step that failed.  
Here is image showing calling outputs() of the fail action in the TryScope gets valid data in the Catch Scope.
Catch on Output of Failing Action withint the TryScope works.jpg
 
After all that .. here is my Question:
 
Is there a way to either:
  •  Get the error result as reported by the scope?
    OR
  •  Use a for-each to and walk through each Action within the scope so I can loop through the error handling...  something like
    • For Each Action in Scope X 
      • Compose from ErrorRaw
      • If status not equal to 200 then error occurred
      • if headers contains SPRequestGUID then SharePoint failure
        • Get headers:request-id, 
        • Confirm body:status = StatusCode
        • Get body:message
        • Test that body:message not null
        • Load all of that into Flow-wide ErrorCollect array variable

 

Callouts to people who might have already solved this...   @FlowJoe or @TomaszPoszytek 

 
I hope someone already has this, because hand crafting the error logic will be a big pain otherwise.
 
Thank you in advance! 
 
4 REPLIES 4
Highlighted

Re: Trying to get error details from a prior scope - outputs('TryScope-LoadLookupDataFromSharePointLists') returns null

Hi!

 

First, sorry for my late response 🙂

Regarding error handlings - instead of using "outputs('TryScope-LoadLookupDataFromSharePointLists')" function you should use result('TryScope-LoadLookupDataFromSharePointLists') and then parse the returned JSON. That fx returns all the execution details about each action inside the scope.

 

Please check out my post about it: https://poszytek.eu/en/microsoft-en/office-365-en/powerautomate-en/try-catch-pattern-in-microsoft-fl...

 

If you have more questions I am here to help 🙂

 

Regards,

Tomasz

Highlighted
Frequent Visitor

Re: Trying to get error details from a prior scope - outputs('TryScope-LoadLookupDataFromSharePointLists') returns null

Tomasz,

 

I'll try result now, thank you!

Highlighted
Frequent Visitor

Re: Trying to get error details from a prior scope - outputs('TryScope-LoadLookupDataFromSharePointLists') returns null

Tomasz,

 

Result is working .. but the odd thing is the expression editor treats it like non-intelisense thing.

 

See imageNo result function in expression editor.jpg

 

See there is no Result .. removeProperty, replace, and range.. but that is it...

And after calling result, I have to build my own parse JSON to get status.

 

Maybe result() is a preview flow feature?

 

Thanks again!

 

Highlighted

Re: Trying to get error details from a prior scope - outputs('TryScope-LoadLookupDataFromSharePointLists') returns null

Hey! Yes, that function from Logic Apps, but since Power Automate is built on top of them, you're able to use some of its features too 🙂

Enjoy!

 

P.S.

If you find my answer as a solution to your question please mark is as "answer" 🙂

 

Regards,

Tomasz

Helpful resources

Announcements
firstImage

Super User Program Update

Three Super User rank tiers have been launched!

firstImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

firstImage

Join the new Power Virtual Agents Community!

We are excited to announce the launch of Power Virtual Agents Community. Check it out now!

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!

Top Solution Authors
Top Kudoed Authors
Users online (6,601)