Embed a report page using an iframe

Use an inline frame (iframe) to embed a page from which a report can be generated, in your custom web app.

Prerequisites

The following steps require you to already have a survey published and an report template uploaded. If you do not already have a survey see Create and publish a survey. For detailed guidance on report templates and generating reports directly through the Survey123 website, see Report templates.

Steps

  1. To configure the required URL parameters for the report page, start with the URL https://survey123.arcgis.com/featureReport, then add the following required parameters:

    • surveyItemId - The survey item ID for which you are generating a report. This provides the context for the survey questions in the report.
    • featureLayerUrl - The source feature layer or the result feature layer view of the survey. This is where the data to populate the report comes from. The value should look like https://services1.arcgis.com/oC086ufSSQ6Avnw2/arcgis/rest/services/serviceName/FeatureServer/0.
    • queryParameters - A JSON string whose value will be passed to the query operation to filter data as input features for the report.

    To put these together, your report page URL should look similar to this:

    Use dark colors for code blocksCopy
    1
    https://survey123.arcgis.com/featureReport?surveyItemId=<surveyId>&featureLayerUrl=<feature layer URL>&queryParameters={"where": "STATUS = 'broken'","orderByFields":"inspectionDate DESC","resultRecordCount":10}

    To quickly generate the report URL with your current settings, go to the Data tab of the Survey123 website, click the Report link button under the Report panel to open a dialog that provides the URL to embed your current report settings in a web page.

  2. In your custom web app, create an iframe element and add HTML that represents the report page.

Parameters

When you embed a report page in either ArcGIS Dashborads or your custom web app, you can add parameters to control the way the report page is displayed.

The following example displays the report page in the embed element in ArcGIS Dashboards, which allows you to generate a report for the selected features:

Use dark colors for code blocksCopy
1
https://survey123.arcgis.com/featureReport?featureLayerUrl=https://services1.arcgis.com/oC086ufSSQ6Avn00/arcgis/rest/services/<service name>/FeatureServer/0&queryParameters=%7B%22objectIds%22%3A%22{field/objectid}%22%7D&inputFeatureTemplate=Feature%20%7Bobjectid%7D%3A%20%7Buntitled_question_1%7D&surveyItemId=<surveyId>

Available parameters are listed in the following table:

ParameterRequiredDescriptionExample
surveyItemIdYesThe survey item ID you generate a report for. This provides the report context of survey questions.surveyItemId=123456
featureLayerUrlYesThe source feature layer or the result feature layer view of the survey. This is where the data comes from to populate the report.featureLayerUrl=https://services1.arcgis.com/oC086ufSSQ6Avnw2/arcgis/rest/services/survey123_ae434e9a0b504915b6e57c6351e19009/FeatureServer/0.
queryParametersYesThis is the same parameter used in the report REST API, a JSON string whose value will be passed to the query operation to filter data as input features for the report. where, objectIds, orderByFields, and resultRecordCount are supported.For example, in a hydrant inspection layer, {"where": "STATUS = 'broken'","orderByFields":"inspectionDate DESC","resultRecordCount":10} will send the latest 10 hydrant features in broken status to the report.
portalUrlNoSpecifies the URL to the portal where the survey and feature layer item is hosted. For instance, when connecting to your ArcGIS Enterprise.portalUrl=https://yourportal.com/portal
clientIdNoThe Client ID when registering the app (parent page) in ArcGIS Online. Ignore this parameter if you are embedding the page into ArcGIS apps (e.g., ArcGIS Dashboards).clientId=abc123
showNoComma-separated array. Only the elements specified in this list will be shown. Supported elements: inputFeatures, selectTemplate, fileOptions, reportName, saveToAGSAccount, outputFormat, showCredits, recentReports, navbar. The "Output settings" section title shows up when any of the following shows: fileOptions, reportName, saveToAGSAccount, outputFormat.show=navbar,inputFeatures,selectTemplate,outputFormat
hideNoComma-separated array. All elements except those specified in this list will be shown. Supported elements are the same as with the show parameter.hide=navbar,inputFeatures,selectTemplate,outputFormat
inputFeatureTemplateNoDefines how a feature displays in the “Input features” section. Use {<fieldName>} to refer to an attribute value.For example, inputFeatureTemplate=Hydrant {objectid}, Status: {status} -> Hydrant 1245, Status: broken
reportTemplateIdsNoA comma-separated string for report template item IDs. If present, the report template dropdown list only shows templates specified in this list. Otherwise, the dropdown list shows all templates related to the survey.reportTemplateIds=abc123,xyz456
labelNoA JSON string to overwrite text labels for each element.label={"inputFeatures":"报告内容","generateReport":"生成报告"}
pageTitleNoSpecifies the title of this page.pageTitle=Inspection report

What's next?

Automate the creation of a richly formatted printable report from survey responses using the REST API reference.

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.