Select to view content in your preferred language

Survey123 Create Report Action Failing

3688
19
Jump to solution
06-19-2023 04:42 AM
RobertAnderson3
MVP Regular Contributor

I've set up a bunch of Power Automate flows with the Create Report function and it's a beautiful tool for many workflows we have.

However, I am finding on an unfortunately regular basis that the report isn't returning any results?

The action Create Report itself marks as "Successful" but then the "Upload File from URL" action fails because "A value must be provided for source path" so when I look further into the "Create Report" I find it has returned an error, a few different ones 'Internal Server side error' (I think this was Esri server errors mid last week) or 'Error assembling data' or 'Error querying data'

But when I run them again, without making any changes to the data or webhook, they work without an issue.

I'm curious if there's something I'm missing (other than a try-catch to run it again if the output is an error) or why the Create Report action marks as successful when it has in fact failed.

Has anyone else been having similar issues?

1 Solution

Accepted Solutions
RobertAnderson3
MVP Regular Contributor

Amazing, thank you for that @abureaux !

I did end up going another way with it for the Create Report action and I THINK this should work too? A little simpler because I can work with dynamic content instead of the whole JSON.

RobertAnderson3_0-1687439803691.png

I initialized a variable reportSuccess and in a Scope (Try) I added a Do Until where the Create Report runs, and then updates the variable based on the jobStatus return, so it will run until it is esriJobSucceeded

I then included the rest of my actions in the Try, and the last step I have outside of the Try is Send an Email with the Configure run after set to failed, skipped or timed out.

I also have the reportError variable which just accepts the body of the return from Create Report and puts it in a text file attachment to my email. My only issue with that right now is it doesn't retain any structure so it's just a big block of text. I'd love to parse the return for the error messages themselves, but it looks like the return changes depending on what happened so I'm not sure how to do that with consistency.

I also added a direct link to the flow run that failed in my email so that's super handy, and maybe easier. 

View solution in original post

0 Kudos
19 Replies
abureaux
MVP Frequent Contributor

I have a large number of Power Automate flows generating reports for my surveys constantly. Errors are rare, but not unheard of. And as you pointed out, simply rerunning the flow will have it succeed. 

You mentioned that Create Report was successful, but then also mentioned that there was an error in that step. Are you using Esri's Power Automate Action, or is this a custom flow? If this is Esri's, I have never used it. If this is a custom one, what does your Do Until step look like? To generate a report, you will be waiting for the server to "finish" generating the report and will want the loop to look like this:

abureaux_0-1687182351855.png

@or(equals(variables('jobStatus'), 'esriJobSucceeded'), equals(variables('jobStatus'), 'esriJobPartialSucceeded'), equals(variables('jobStatus'), 'esriJobFailed'))

This step failing is where I see 100% of these random errors. In fact, I had a flow fail just this morning:

abureaux_1-1687182531762.png

(It automatically reran and was successful)

In my case, I have error handling set up in the flow. Basically, if there is an error, the flow will reset and run again. I have never seen one of these mystery errors happen more than once in a row, and only at a frequency of every (very rough guess) 1/50 to 1/100 submissions. 

Honestly, if you are experiencing the same thing as me, I don't think Esri support can help. The errors are far to transitory to analyze. I would suggest going the same route as me with the multi-stage report generation.

RobertAnderson3
MVP Regular Contributor

Thank you!

I am using the Esri Create Report action that they put out this year, so I just have that action in the flow itself. I do not have a "Do Until" in my flow at this point in time, but I think that will be the approach I take to avoid this issue, so I do really appreciate the example you included!

So basically the Action still runs and gives the little green checkmark saying it worked, it returns status code 200 either way at the end.

RobertAnderson3_0-1687185596599.png

So it knows, it just powers through it and it's on me for not catching it. Can you set a delay on the do until to try again? 
 
I wanted to bring it up too just in a "be aware" kinda way with how much more they've been popping up the past week or so as well.
 
Actually, @abureaux could you share the whole Do Until set up? I tried putting it in and it just spun for forever so I didn't quite get the set up I guess.
0 Kudos
abureaux
MVP Frequent Contributor

For sure. The Do Until step I am using should work with this Esri Action, based on what I am seeing in the JSON output. But there are things I do before this to set it up, so there will need to be tweaking one way or another to get this to work in your set-up.


For context, I believe the Esri Create Report Action would be the equivalent of my "HTTP - Create Report" step:

abureaux_1-1687202444840.png

Here are the components (starting at the first Parse JSON):

1. Parse JSON - Job ID + Job Status

abureaux_2-1687202530558.png

Body = The previous "HTTP - Create Report" in my first screen cap (so, probably your Esri Create Report Action?)

Schema =

 

{
    "type": "object",
    "properties": {
        "jobId": {
            "type": "string"
        },
        "jobStatus": {
            "type": "string"
        },
        "submitted": {
            "type": "integer"
        },
        "resultInfo": {
            "type": "object",
            "properties": {
                "title": {
                    "type": "string"
                }
            }
        },
        "inputInfo": {
            "type": "object",
            "properties": {
                "jobType": {
                    "type": "string"
                },
                "parameters": {
                    "type": "object",
                    "properties": {
                        "featureLayerUrl": {
                            "type": "string"
                        },
                        "queryParameters": {
                            "type": "object",
                            "properties": {
                                "objectIds": {
                                    "type": "string"
                                }
                            }
                        },
                        "templateItemId": {
                            "type": "string"
                        },
                        "portalUrl": {
                            "type": "string"
                        }
                    }
                }
            }
        },
        "success": {
            "type": "boolean"
        }
    }
}

 

 

2. Set variable - jobId

abureaux_3-1687202647096.png

ValuejobId from the previous Parse JSON

3. Do Until - Create Report Job Finished

abureaux_4-1687202781152.png

3a. Do Until's Logic. Must be entered in Advanced mode. 

 

@or(equals(variables('jobStatus'), 'esriJobSucceeded'), equals(variables('jobStatus'), 'esriJobPartialSucceeded'), equals(variables('jobStatus'), 'esriJobFailed'))

 

 3b. Delay - 5 seconds (Get jobStatus)

abureaux_5-1687202892679.png

Simply a 5 second delay. This helps the Loop run smoothly.

3c. HTTP - Get jobStatus

abureaux_7-1687202992609.png

This one will be interesting... JobId you already have from above. But Token I set previously. Not sure how to best accommodate that.

3d. Parse JSON - Result Info

abureaux_8-1687203402710.png

Body = Previous HTTP step

Schema =

 

{
    "type": "object",
    "properties": {
        "jobId": {
            "type": "string"
        },
        "jobStatus": {
            "type": "string"
        },
        "submitted": {
            "type": "integer"
        },
        "completed": {
            "type": "integer"
        },
        "resultInfo": {
            "type": "object",
            "properties": {
                "title": {
                    "type": "string"
                },
                "totalCount": {
                    "type": "integer"
                },
                "resultFiles": {
                    "type": "array",
                    "items": {
                        "type": "object",
                        "properties": {
                            "objectIds": {
                                "type": "array",
                                "items": {
                                    "type": [
                                        "integer",
                                        "string",
                                        "number"
                                    ]
                                }
                            },
                            "name": {
                                "type": "string"
                            },
                            "size": {
                                "type": "integer"
                            },
                            "url": {
                                "type": "string"
                            }
                        },
                        "required": [
                            "objectIds",
                            "name",
                            "size",
                            "url"
                        ]
                    }
                },
                "succeededObjectIds": {
                    "type": "array",
                    "items": {
                        "type": "integer"
                    }
                },
                "failedObjectIds": {
                    "type": "array"
                },
                "details": {
                    "type": "array"
                }
            }
        },
        "inputInfo": {
            "type": "object",
            "properties": {
                "jobType": {
                    "type": "string"
                },
                "parameters": {
                    "type": "object",
                    "properties": {
                        "featureLayerUrl": {
                            "type": "string"
                        },
                        "queryParameters": {
                            "type": "object",
                            "properties": {
                                "objectIds": {
                                    "type": "string"
                                }
                            }
                        },
                        "templateItemId": {
                            "type": "string"
                        }
                    }
                }
            }
        }
    }
}

 

3e. Set variable - jobStatus

abureaux_9-1687203488117.png

Value = jobStatus from previous Parse JSON step.

4. Condition - Job Succeeded or Failed

abureaux_10-1687203746552.png

 

This Condition is probably the most important part. If the report doesn't print, it goes to the If no branch, which resets the flow. If the report does print, it hits the If yes branch, and does whatever the next steps are.

RobertAnderson3
MVP Regular Contributor

Amazing, thank you for that @abureaux !

I did end up going another way with it for the Create Report action and I THINK this should work too? A little simpler because I can work with dynamic content instead of the whole JSON.

RobertAnderson3_0-1687439803691.png

I initialized a variable reportSuccess and in a Scope (Try) I added a Do Until where the Create Report runs, and then updates the variable based on the jobStatus return, so it will run until it is esriJobSucceeded

I then included the rest of my actions in the Try, and the last step I have outside of the Try is Send an Email with the Configure run after set to failed, skipped or timed out.

I also have the reportError variable which just accepts the body of the return from Create Report and puts it in a text file attachment to my email. My only issue with that right now is it doesn't retain any structure so it's just a big block of text. I'd love to parse the return for the error messages themselves, but it looks like the return changes depending on what happened so I'm not sure how to do that with consistency.

I also added a direct link to the flow run that failed in my email so that's super handy, and maybe easier. 

0 Kudos
abureaux
MVP Frequent Contributor

Nice! This looks good.

I do have two things to consider though:

  1. Add esriJobPartialSucceeded. This does come up from time to time, and a report is still generated. You can monitor your flow to see if it's worth it for you.
  2. Without esriJobFailed, all failures will take the full duration of the Do Until to timeout. Again, may not be a big deal for you, but I thought it was worth mentioning.
0 Kudos
RobertAnderson3
MVP Regular Contributor

Thank you for the feedback!

I was curious about the esriJobPartialSucceeded, I have no idea what that result means, what would the break down be to make it partial?

And how do you mean with the esriJobFailed? I want it to re-try when I get the failure because I was finding a bunch of random no reason failures that worked if it tried again, I set a cap of like 10 re-tries to avoid problems on unsolvable problems (like the ever fun 14 day token timeout).

0 Kudos
abureaux
MVP Frequent Contributor

Honestly, that result may no longer exist! It's been a while since I've looked at that documentation. You should be fine with just esriJobSucceeded.

Also, I didn't look at your Create Report step close enough, and I believe you are correct. It should do the thing until the other thing is done. Honestly, I haven't had the time to update my flow template to include Esri's new Create Report Action.

Your flow is looking good! Best of luck 🙂

RobertAnderson3
MVP Regular Contributor

All good haha, we all have our own stuff to focus on! 

Yeah it doesn't look like it's mentioned in that documentation now it must have been removed. 

And if you have one working without the Create Report action I wouldn't worry too much about updating the flows right now, especially not until they have the 14 day token timeout improved at least!

0 Kudos
DanLissick
Occasional Contributor

Hey Robert,

By chance could you provide more information on your final Flow? I am having trouble replicating the final solution. Thank you!

0 Kudos