Generate Feature Report in Power Automate

4287
32
Jump to solution
07-07-2021 02:56 PM
Wade_Bryan
New Contributor III

Does anyone know if the ability to generate Surevey123 Feature Reports using Power Automate has been fixed? I've used the work arounds described in previous posts but some of my surveys are getting a bit complicated to continue to do that.

2 Solutions

Accepted Solutions
Ruth_JiatengXu
Esri Contributor

Hi @Wade_Bryan 

Thanks for your reply! I will log your comment in our internal repo.

Thanks,

Ruth

View solution in original post

0 Kudos
abureaux
Occasional Contributor III

It's not so much that it doesn't work with this version of Survey123, but rather Integromat doesn't currently work with Enterprise 10.9. If you are on 10.8.1 or earlier, you are fine.

As for Power Automate, here are the general steps:

  1. Create the custom connector: https://support.esri.com/en/technical-article/000025025 (troubleshoot said connection in two weeks: https://support.esri.com/en/technical-article/000022795)
  2. Create a new Flow and add your new When a survey response is submitted as the trigger
  3. Add 8 Initialize Variable and customize as per below (Name / Type / value)
    1. templateItemId / string / <Your survey's templateItemId>
      1. Go to your ArcGIS Survey123 page
      2. Go to your survey's Data page
      3. Click Report
      4. Under step #2 in the Report slide-out, select your template from the drop-down (do this even if it already looks selected)
      5. Now look in your URL bar. You will see something like: templateItemId:62abcdef123456abcdef123456abcdef123456abcd63
      6. Grab that long alphanumeric string. That is your template's Item ID
    2. reportOutputType / string / <pdf> or <docx>
    3. jobStatus / string / <blank>
    4. jobId / string / <blank>
    5. reportUrl / string / <blank>
    6. objectId / string / objectId
    7. featureLayerUrl / string / serviceUrl
    8. formItemId / string / formItemID
  4. ... I recommend adding a Parse JSON here to grab all the values mentioned above as it can make your life a lot easier, but I feel like adding those instructions may be too convoluted for this super quick guide. There isn't anything wrong with grabbing them from the initial response, and for some things actually works better (I blame PowerAutomate). I omitted a few things (like some Set Variable following my Parse JSON) for the sake of simplicity.
  5. Add an HTTP and configure as per below. username and password are plain text and should be your Creator level account that will be hosting this survey. Personally, I only allow a single account to publish our live surveys to simplify the automation process (this also helps in other areas, such as general content control). TIP: Name your Steps. Below, I named mine HTTP - Generate Token
    abureaux_3-1629911417658.png
  6. Add a Parse JSON
    1. Content is the Body of your HTTP above.
      abureaux_4-1629911627472.png
    2. The Schema? Just copy-paste:
      {
          "type""object",
          "properties": {
              "token": {
                  "type""string"
              },
              "expires": {
                  "type""integer"
              },
              "ssl": {
                  "type""boolean"
              }
          }
      }
  7. Add another HTTP and format as per below:
    abureaux_5-1629911927763.png
  8. As per the above image, I added a 5 second delay. It seems to help, but maybe I am just imagining it.
  9. Add an HTTP and format as per below
    abureaux_6-1629913038503.png
  10. Add a Parse JSON
    1. Content is the Body of your HTTP above. (same as the previous Parse JSON step)
    2. Just copy-paste the 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"
              }
          }
      }
  11. Add a Set Variable
    Name = jobId
    Value = jobId (from the Parse JSON directly above)
  12. Add a Do until
    1. Click "Edit in advanced mode" and add this:
      @or(equals(variables('jobStatus'), 'esriJobSucceeded'), equals(variables('jobStatus'), 'esriJobPartialSucceeded'), equals(variables('jobStatus'), 'esriJobFailed'))
    2. Within the Do Until, add these steps:
      1. Delay - 5 seconds
      2. HTTP
        abureaux_7-1629913942950.png
      3. Parse JSON
        1. Body is from the HTTP directly above
        2. Scheme, copy-paste:
          {
              "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"
                                  }
                              }
                          }
                      }
                  }
              }
          }
      4. Set Variable
        Name = jobStatus
        Value = jobStatus (from Parse JSON above)
  13. Following the Do Until, add a Condition and set it to Or
    abureaux_8-1629914261924.png
  14. On the "Yes" side:
    1. Add an Apply to each
      Output from previous step: resultFiles (From the Parse JSON in my step #12 above)
    2. Within the Apply to each, add Set Variable
      Name = reportUrl
      Value = url (From the Apply to each you are currently in)
      abureaux_9-1629914981294.png
    3. Below the Apply to Each, add HTTP
      abureaux_10-1629915071228.png
    4. DONE! If you want to send your pdf/docx somewhere (e.g., in an email), attach the body of the above HTTP. When you specify the file name, dont forget to add the extension. Example:
      abureaux_11-1629915187399.png

*Corrected a couple spelling errors*

*Edit 2. Forgot some JSON*

View solution in original post

32 Replies
Ruth_JiatengXu
Esri Contributor

Hi @Wade_Bryan 

Currently, Survey123 does not support generating report using power automate. I encourage you to contact Esri Support, and our Support team will assign an official bug number for your records. This number can be used to search for and subscribe to the bug on the Esri Support site. If the issue is reported by other customers it will be attached to the same bug report, which helps us assess the impact of the issue and prioritize it accordingly.

Since you mentioned that you are using custom power automate connector for report generating, this developer documentation of the Report REST API might be helpful: https://developers.arcgis.com/survey123/api-reference/rest/report/. Also, if it is possible could you please let us know what is the issue you encountered with your workflow? 

Thanks,

Ruth

Wade_Bryan
New Contributor III

Ruth,

I wasn't so much an issue just a pain to do the work around. My organization currently doesn't allow us to use integromat and I would like to generate a feature report that then gets emailed to s supervisor when a particular survey is submitted.  Mostly just hoping that the option to generate a report using power automate will be available soon

Ruth_JiatengXu
Esri Contributor

Hi @Wade_Bryan 

Thanks for your reply! I will log your comment in our internal repo.

Thanks,

Ruth

0 Kudos
abureaux
Occasional Contributor III

I can confirm that you can generate a Survey123 Feature Report via Power Automate flows. I am using it for all of our automations right now (mainly because Integromat isn't working in 10.9).

0 Kudos
Wade_Bryan
New Contributor III

I would be curious to know how you are doing that as there isn't an option to generate a feature report in power automate. I know there are custom options 1 of which I am currently using but it requires consistent monitoring to ensure functionality. Integromat though allows me to create the report using my report template from Survey123. You are the first person that I've heard from about Integromat not working with the newest survey123 version. 

0 Kudos
abureaux
Occasional Contributor III

It's not so much that it doesn't work with this version of Survey123, but rather Integromat doesn't currently work with Enterprise 10.9. If you are on 10.8.1 or earlier, you are fine.

As for Power Automate, here are the general steps:

  1. Create the custom connector: https://support.esri.com/en/technical-article/000025025 (troubleshoot said connection in two weeks: https://support.esri.com/en/technical-article/000022795)
  2. Create a new Flow and add your new When a survey response is submitted as the trigger
  3. Add 8 Initialize Variable and customize as per below (Name / Type / value)
    1. templateItemId / string / <Your survey's templateItemId>
      1. Go to your ArcGIS Survey123 page
      2. Go to your survey's Data page
      3. Click Report
      4. Under step #2 in the Report slide-out, select your template from the drop-down (do this even if it already looks selected)
      5. Now look in your URL bar. You will see something like: templateItemId:62abcdef123456abcdef123456abcdef123456abcd63
      6. Grab that long alphanumeric string. That is your template's Item ID
    2. reportOutputType / string / <pdf> or <docx>
    3. jobStatus / string / <blank>
    4. jobId / string / <blank>
    5. reportUrl / string / <blank>
    6. objectId / string / objectId
    7. featureLayerUrl / string / serviceUrl
    8. formItemId / string / formItemID
  4. ... I recommend adding a Parse JSON here to grab all the values mentioned above as it can make your life a lot easier, but I feel like adding those instructions may be too convoluted for this super quick guide. There isn't anything wrong with grabbing them from the initial response, and for some things actually works better (I blame PowerAutomate). I omitted a few things (like some Set Variable following my Parse JSON) for the sake of simplicity.
  5. Add an HTTP and configure as per below. username and password are plain text and should be your Creator level account that will be hosting this survey. Personally, I only allow a single account to publish our live surveys to simplify the automation process (this also helps in other areas, such as general content control). TIP: Name your Steps. Below, I named mine HTTP - Generate Token
    abureaux_3-1629911417658.png
  6. Add a Parse JSON
    1. Content is the Body of your HTTP above.
      abureaux_4-1629911627472.png
    2. The Schema? Just copy-paste:
      {
          "type""object",
          "properties": {
              "token": {
                  "type""string"
              },
              "expires": {
                  "type""integer"
              },
              "ssl": {
                  "type""boolean"
              }
          }
      }
  7. Add another HTTP and format as per below:
    abureaux_5-1629911927763.png
  8. As per the above image, I added a 5 second delay. It seems to help, but maybe I am just imagining it.
  9. Add an HTTP and format as per below
    abureaux_6-1629913038503.png
  10. Add a Parse JSON
    1. Content is the Body of your HTTP above. (same as the previous Parse JSON step)
    2. Just copy-paste the 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"
              }
          }
      }
  11. Add a Set Variable
    Name = jobId
    Value = jobId (from the Parse JSON directly above)
  12. Add a Do until
    1. Click "Edit in advanced mode" and add this:
      @or(equals(variables('jobStatus'), 'esriJobSucceeded'), equals(variables('jobStatus'), 'esriJobPartialSucceeded'), equals(variables('jobStatus'), 'esriJobFailed'))
    2. Within the Do Until, add these steps:
      1. Delay - 5 seconds
      2. HTTP
        abureaux_7-1629913942950.png
      3. Parse JSON
        1. Body is from the HTTP directly above
        2. Scheme, copy-paste:
          {
              "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"
                                  }
                              }
                          }
                      }
                  }
              }
          }
      4. Set Variable
        Name = jobStatus
        Value = jobStatus (from Parse JSON above)
  13. Following the Do Until, add a Condition and set it to Or
    abureaux_8-1629914261924.png
  14. On the "Yes" side:
    1. Add an Apply to each
      Output from previous step: resultFiles (From the Parse JSON in my step #12 above)
    2. Within the Apply to each, add Set Variable
      Name = reportUrl
      Value = url (From the Apply to each you are currently in)
      abureaux_9-1629914981294.png
    3. Below the Apply to Each, add HTTP
      abureaux_10-1629915071228.png
    4. DONE! If you want to send your pdf/docx somewhere (e.g., in an email), attach the body of the above HTTP. When you specify the file name, dont forget to add the extension. Example:
      abureaux_11-1629915187399.png

*Corrected a couple spelling errors*

*Edit 2. Forgot some JSON*

Wade_Bryan
New Contributor III

That is what I currently do and want to stop doing. Also, I am using AGOL and not Enterprise. But I appreciate the replies. I'll just keep doing what we are doing until I can get approval for integromat or Esri decides to provide support in power automate.

0 Kudos
abureaux
Occasional Contributor III

Then I am not sure I understand.

When you say "...it requires consistent monitoring to ensure functionality.", what do you mean? My flows are all completely autonomous.

And what do you mean by "Integromat ... allows me to create the report using my report template from Survey123"? Power Automate lets you do the same thing.

0 Kudos
RyanB1
by
New Contributor

Hi Abureaux

Looking at step 12 part 3. At the moment its coming up with the below. Is this correct? or is a txt file i cant get access to?

  1. Parse JSON
    1. Body is from the HTTP directly above
    2. Scheme, copy-paste:
      2.txt
0 Kudos