The Survey123 website's report functionality allows you to design your own personalized templates and produce multiple reports at once.
A report can contain the following:
- A summary section
- A single survey record
- A single survey record and a summary section
- Multiple survey records
- Multiple survey records and a summary section
Note:
Printing reports is an ArcGIS Online Premium Service and consumes credits. For more information, see Print reports.
Printing reports in ArcGIS Enterprise does not consume credits but does have limitations.
A report template is a Microsoft Word file (.docx) that provides placeholder text with specific syntax. When printing a report, this placeholder text is replaced with the contents of the corresponding fields from the survey response. This placeholder text can be used with any formatting, tables, images, or other personalization to create a template specific to your needs.
To create a template, click the Report button on the bar above the map on the Data tab, and click Manage templates. A new window appears, allowing you to download a sample, upload a new template, or edit the name and summary of an existing one. Click New template to upload a new report template, while also providing a name and summary for your template once uploaded. Alternatively, you can use the Download sample template link to download a sample template based on your survey.
Note:
Report templates can only be uploaded by the survey owner and organization administrators.
Sharing the results of a survey to everyone, an organization, or a group, will also share the report templates associated with the survey.
Expressions
The response to a question can be displayed in a report template by providing its name encased with curly brackets such as { and }, and preceded by a dollar sign. Any string value included in an expression must be enclosed in double quotes.
The following would display the response from a text question called firstname.
${firstname}
In addition to displaying the response to a question in a report, keywords can be used to display other useful information. The following would display the current date and time when printing a report:
${$date}
If the result is an array, the array can be iterated using # as a start tag and / as an end tag within the curly brackets. The following would print all image files on separate lines:
${#image1}
${$file}
${/}
You can also use expressions to refine how responses are displayed. An expression can be a single question name or keyword (as above), a calculation involving one or more questions or keywords, or a question name or keyword with methods and parameters to constrain or apply style to the response. An expression uses the following notation:
${questionname or keyword | method:parameter}
An expression may include multiple methods and parameters or none at all. Parameters may be either values from other questions or a fixed value.
The following expression would display the calculation of a number question called floweringtrees divided by a number question called totaltrees. When referring to multiple questions in the same expression, the individual question names only need to be directly named and do not need additional curly brackets.
${floweringtrees / totaltrees}
The following expression would display the x-coordinate value from the location question, where getValue is the method and x is the parameter.
${location | getValue:"x"}
The following expression would evaluate as true if the response to a question called fruitcolor is not equal to red.
${if fruitcolor!="red"}The fruit is not red.${/}
Strings can be concatenated in an expression by joining them with a plus sign. This expression uses this concatenation to pass the contents of a question called field_0 to a QR code-generating service, creating a QR code for the question's response.
${$image | src:"https://barcode.tec-it.com/barcode.ashx?code=QRCode&data="+field_0}
Not all question types support expressions and methods. The following table lists which methods and parameters you can use with which question types.
Method | Parameters | Connect question type | Web designer question type | Description |
---|---|---|---|---|
getValue | - | All question types | All question types | Retrieves the raw data value from the feature layer, or raw image from an attachment. |
getValue | x, y, z, wkid | geopoint | Map | Retrieves the x, y, z coordinates individually in a specified spatial reference. The wkid parameter is optional, and will be the same as the spatial reference of the feature layer if omitted. |
getValue | length, area, unit, measurement type | geotrace, geoshape | Map | Returns the length of a polyline, or the perimeter or area of a polygon, in given units and whether the measurements are planar or geodesic. Default measurement type is geodesic. |
getValue | name, size | image, audio, file | Image, Signature, Audio, File | Returns the file name or size of an attachment. |
getValue | width, height, x, y, date, time, direction | image | Image, Signature | Width and height return the integer value of the image width and height in pixels, and x, y, date, time, and direction return values read from the image EXIF, if present. |
getValue | count | begin repeat, image, audio, file | Repeat, Image, Signature, Audio, File | Returns the total count of repeats or attachments. |
getValue | position | begin repeat, image, audio, file | Repeat, Image, Signature, Audio, File | Returns an integer equal to the 1-indexed position in the array. |
getValue | duration | audio, file | Audio, File | Returns the length of audio recordings in seconds. Caution:Duration will not be returned in responses collected in the web app when using Safari. |
appearance | multiline | text | Multiline text | Used to retain the line breaks in the string. If no appearance is specified, answer returns a single line string. |
appearance | bullets | select_multiple | Multiple select | Returns answer in bullet format. |
checked | choice name | select_one, select_multiple | Multiple select, Single select, Single select grid, Dropdown, Likert scale, Rating | Returns a checked check box if the field value equals the choice name; otherwise, returns an unchecked check box. |
selected | choice name | select_one, select_multiple | Multiple select, Single select, Single select grid, Dropdown, Likert scale, Rating | If a coded value domain exists, returns true if the field value equals the choice name; otherwise, returns false. |
countSelected | - | select_one, select_multiple | Multiple select, Single select, Single select grid, Dropdown, Likert scale, Rating | Returns the number of selected choices. |
selectedAt | index | select_one, select_multiple | Multiple select, Single select, Single select grid, Dropdown, Likert scale, Rating | Returns the string at the index position in the choice list. Index starts at zero. |
locale | language code | date, dateTime, start, end, decimal | Date, Date and time, Number | Returns localized date, time, and number. |
format | format string | date, dateTime, integer, decimal, start, end | Date, Date and time | Returns a formatted date string. |
utcOffset | offset value | date, dateTime, start, end | Date, Date and time | Returns a date or date-time value that is shifted by the UTC offset value. |
mapSettings | web map item ID, map scale | geopoint, geotrace, geoshape | Map | Specifies basemap and scale when printing the map image. Legacy:Replaced by map and mapScale. |
mapExtent | xmin, ymin, xmax, ymax, wkid | geopoint, geotrace, geoshape | Map | Specifies fixed map extent when printing the map image. The wkid parameter is optional, and will be set to 4326 (WGS 1984) if omitted. |
map | web map item ID | geopoint, geotrace, geoshape | Map | Specifies basemap when printing the map image. |
mapScale | map scale | geopoint, geotrace, geoshape | Map | Specifies map scale when printing the map image. |
mapFilters | layer ID in web map JSON, query parameters | geopoint, geotrace, geoshape | Map | Specifies one or more filters of feature layers in a web map when printing the map image. |
rotate | degrees | geopoint, geotrace, geoshape, image | Map, Image | Specifies the rotation angle of the map or image. |
drawingInfo | currentLayer, feature layer URL | geopoint, geotrace, geoshape | Map | Specifies the drawing information when printing the map image, including symbol, label, and transparency. |
src | image URL | - | - | Specifies the source URL of a dynamic image element. |
size | width, height, max width, max height | image | Image | Specifies the size of the printed image. |
round | places | decimal, geopoint, geoshape, geotrace | Number | Rounds a decimal number to specified decimal places. |
useGrouping | boolean | decimal | Number | If true, returns a number with grouping separators determined by the locale; otherwise, if false, no separators used. |
toFixed | places | decimal, geopoint, geoshape, geotrace | Number | Specifies a fixed number of digits after the decimal separator. It will pad zero if required to meet a fixed number of digits. |
The following table lists all keywords that can be used in an expression.
Keyword | Description |
---|---|
$date | Inserts the current date and time when printing the report. By default, it outputs the current date in using current locale format. Examples:
|
$image | Inserts an image element in the report. Use the src method to specify the image URL. Example:
|
$map | Inserts a map element in the report without referencing a survey question. Example:
|
$shape | Prints the geometry (point, polyline, or polygon) of the current feature on a map. Examples:
|
$attachment | Represents the first attachment, or all attachments of the current feature. Examples:
To iterate all attachments, include start and end tags:
|
$file | Represents the current file when iterating multiple files of an attachment survey question or attachments of a feature. Examples:
|
$feature | Represents the current feature inside an array of features. Example:
|
$layers["<layername>"] or $layers[<layerId>] | References any layer by name or ID in the same feature service as the survey layer. Examples:
|
In the Manage templates window, select Quick reference to open a page containing example syntax for expressions to modify the response displayed in a report for each question in your survey. To copy this syntax, click the Copy to clipboard button, then paste the syntax into a template document. Once a template has been uploaded, use the options in the Report panel to produce your report. For more information, see Print reports.
The following sections describe common use scenarios of expressions for each question type and provide examples.
Text
Multiline text questions—created either by adding a Multiline text question in the Survey123 web designer or using the multiline appearance for a text question in Survey123 Connect—ignore carriage returns by default, displaying the response in a single block of text. An expression can be used to display the response to the question with carriage returns as follows:
${multilinetext1 | appearance:"multiline"}
Place this expression on a dedicated line; otherwise, errors will occur.
Numbers
Basic mathematical operators can be used with numerical questions, which can be used to add, subtract, multiply, divide, or find the modulus of the responses to these questions. The following are examples:
${number1 - 15}
${number1 * 6}
${number1 / number2}
${number1 % number2}
Tip:
If your expression includes a complex mathematical expression, consider using brackets to ensure that the report generation produces the result you expect.
For decimal questions, the round expression can be used to set a maximum number of decimal places to which the value is rounded. The following example rounds the number 3.141592 to the four decimal places of 3.1416:
${decimal1 | round:4}
The toFixed expression can be used to set a maximum number of decimal places to which the value is rounded. The following example fixes the number of decimal places in 3.14 to 3.140:
${decimal1 | toFixed:3}
You can use the format expression to display the response to a number question in a specific way by using placeholder characters. The following placeholder characters are supported.
Character | Description |
---|---|
. | Decimal separator. |
, | If placed in the format, adds group separators, with group size determined by the number of digits between the first group separator placeholder and either the decimal point placeholder or the end of the expression. If not added, no group separators are used. |
0 | Required digits. If the response has fewer than the required number of digits, it will be padded with zeros. |
# | Optional digits. If the response has more than the provided number of digits, the number will be rounded. |
Tip:
The decimal and thousands separators will be displayed in the printed result based on the chosen locale.
The following example returns the response to a maximum of three decimal places with thousands separators, rounding if necessary.
${decimal1 | format:"#,##0.###"}
Images and other attachments
For image questions, sizes can be set to ensure that your reports have images of consistent size. The format for these expressions is as follows:
${image1 | size:width:height:max_width:max_height}
The width and height values control the set size of your image, measured in pixels. While these values are required for the expression, providing a value of 0 will place no restriction on that dimension of your image. For example, the following expression forces the width of your image to be 300 pixels while preserving the aspect ratio of the image:
${image1 | size:300:0}
The maximum height and width values limit the maximum size of an image and are optional values. The following example forces the width of the image to be 300 pixels and restricts the image height to no more than 200 pixels:
${image1 | size:300:0:0:200}
You can use the rotate method to define the clockwise rotation of the image. It accepts values from 0 to 360.
${image1 | size:300:0:0:200 | rotate:90}
Image questions can also have image details extracted and displayed in a survey response. This can be used to display the file name and size of the image as follows:
${image1 | getValue:"name"}
${image1 | getValue:"size"}
${image1 | getValue:"width"}
${image1 | getValue:"height"}
The same method can be used to display EXIF data from the image, showing details of where and when a photo was taken, as follows:
${image1 | getValue:"x"}
${image1 | getValue:"y"}
${image1 | getValue:"date"}
${image1 | getValue:"time"}
${image1 | getValue:"direction"}
To display the original image at its full size and quality, use the expression without any method, or use the getValue expression without any value:
${image1} or ${image1 | getValue:""}
To display the original image at full quality but a set size, use the getValue and size expressions together.
${image1 | getValue:"" | size:300:0}
Note:
If you are setting an image's size while using any other expression parameter, size must be placed last in the expression.
Dates and times are stored as strings in EXIF data, so these values cannot be formatted in a report using the format expression for date and time questions. If formatting these values is important, consider performing the EXIF extraction as part of your survey using the pulldata("@exif") function. For more information, see Images.
The getValue expressions above can also be used to extract data from any valid properties in any type of attachment, including the results of image, audio, and file questions. The properties that can be extracted from all attachments are as follows:
${file1 | getValue:"name"}
${file1 | getValue:"size"}
${file1 | getValue:"globalId"}
${file1 | getValue:"id"}
${file1 | getValue:"contentType"}
${file1 | getValue:"keywords"}
If all attachments to the feature are images, use the following placeholders with each placed on a dedicated line:
${#$attachment}
${$file}
${/}
To return multiple images submitted to the same question in a response, use the image question's name instead of $attachment:
${#image1}
${$file}
${/}
This method is useful for displaying images in ArcGIS Enterprise versions earlier than 10.8.1, or for displaying images that were added to a feature outside of Survey123. The following example displays the file names of all attachments attached to a feature:
${#$attachment}
${$file|getValue:"name"}
${/}
To display an image from online, provide its source URL with the src expression when referring to the $image keyword instead of a question name:
${$image |
src:"https://upload.wikimedia.org/wikipedia/commons/1/13/Esri_Headquarters%2C_Building_Q.jpg"
| size:400:0}
Map
All questions that make use of a map—including geopoint, geotrace, and geoshape—have common methods and parameters that you can use to modify their presentation in reports.
By default, a map in a report will use the web map that is set for the question. If the map scale is set to 0 or the parameter omitted, the map scale is determined by the features in the map as follows:
- If there is only one point feature on the map, the map scale matches the scale set for the question.
- If there is only one line or polygon feature on the map, the map scale is determined by the extent of the feature.
- If there are multiple features on the map, the scale is determined by the extent of all features.
Map questions support setting the web map item ID and map scale as optional parameters. In the following example, a map scale of 1:100,000 is used:
${location | map:"7e2b9be8a9c94e45b7f87857d8d168d6" | mapScale:100000}
For all map questions, you can use the rotate method to define the clockwise rotation of due north in relation to the view. It accepts values from 0 to 360.
${location | map:"7e2b9be8a9c94e45b7f87857d8d168d6" | mapScale:100000 | rotate:90}
If you leave the web map item ID as an empty string, the default basemap for the question is used. If you set the map scale to 0 or omit this parameter, the map will use the default extent set for the question.
The mapExtent method can be used to explicitly set the extent of a map in a report. In the following example, a fixed map extent of Tokyo, Japan, is displayed:
${location | mapExtent:139.7:35.6:139.9:35.8:4326}
Map questions also support the size expression available for image questions. You can use this expression to control the resolution of the map displayed in the report, as shown in the following example:
${location | size:400:400}
You can use the map, mapScale and size expressions together to provide a web map ID and map scale as well as a map image resolution, as shown in the following example:
${location | map:"7e2b9be8a9c94e45b7f87857d8d168d6" | mapScale:100000 | size:400:400}
Note:
If you're setting a map's size while using any other expression method, size must be placed last in the expression.
If your map contains a large number of records, you can use the mapFilters method to limit what records are shown. In the following example, the where parameter is used to filter a web map that only has one layer to show records with a POP2000 greater than 999999:
${location | map:"7e2b9be8a9c94e45b7f87857d8d168d6" | mapFilters:"where=POP2000>999999"}
In the following example of mapFilters, the first parameter filters the cities layer (whose layer id is 18ece64a1fc-layer-5) to show only the first three records that have the highest population that are in the state of California. Separated from the first parameter by a colon, the second parameter filters the states layer (whose layer id is 18ece64a1fc-layer-6) to show only the state of California:
${$map | map:"7e2b9be8a9c94e45b7f87857d8d168d6" | mapFilters:"'18ece64a1fc-layer-5':where=ST='CA'&orderByFields=POP2000 ASC&resultRecordCount=3":"'18ece64a1fc-layer-6':where=stateName='California'"}
Note:
Layer id is a property of the feature layer object of the web map JSON.
By default, a map question will display using a default map symbol, regardless of symbology set in the feature layer. You can use the drawingInfo method to extract and use the drawing information stored in a specific feature layer, including the symbol, label, and transparency used. You can specify this information either from the current layer or from a specific feature layer through a provided URL.
${location | drawingInfo:"currentLayer"}
${location | drawingInfo:"https://.../FeatureServer/0"}
If your survey doesn't contain a map question or you're creating reports for feature layers without an associated survey, the geometry of a record can still be returned using the ${$shape} placeholder.
In a summary section, an expression for a map question displays multiple geometries in the input for your question. If you want to include other responses for an individual report, provide a where expression with the !important tag. For more information, see Additional syntax. The following expression displays all geometries in the layer where the status field value is equal to 'broken':
${location | where:"status='broken' !important" | map:"<itemID>" | size:400:300}
Note:
In the above example map scale is omitted. If you set the map scale to 0 or omit the parameter, and the map contains multiple records, the map will use the combined extent for all records.
You can set the where expression to be an always true statement to ensure that every geometry in the layer is displayed:
${location | where:"1=1 !important"}
This can also be used to display all points within a repeat:
${repeat1.repeatLocation | where:"inspectionId=123 !important" | size:400:300}
The $shape keyword can also be used to return multiple map geometries.
${$shape | where:"1=1 !important" | drawingInfo:"currentLayer" | size:400:300}
The $map keyword can be used to print a map that does not reference a survey question.
${$map | map:"7e2b9be8a9c94e45b7f87857d8d168d6" | mapScale:100000 | size:400:400}
Geopoints
For geopoint questions, you can use expressions to display the latitude or longitude values from the question, as follows:
${location | getValue:"x"}
${location | getValue:"y"}
You cannot display both values with one expression; if both values are needed, you must use both expressions.
Tip:
You can also display the altitude value through a similar expression but only if the underlying feature layer supports z-values:
${location | getValue:"z"}
By default, latitude, longitude, and altitude values return the original value provided in the survey response, without truncation. As these values can often be much longer than needed in a report, consider using the round or toFixed expressions to round the value to a specific decimal place.
${location | getValue:"x" | round:3}
${location | getValue:"x" | toFixed:3}
By default, these values are output to the same spatial reference used by the survey's feature layer. You can set a different spatial reference as an additional parameter by providing its WKID:
${location | getValue:"x":4326}
Geotrace and geoshape
For geotrace and geoshape questions, you can use the getValue expression to display the length of the line or the perimeter of the polygon, respectively:
${polyline1 | getValue:"length":"meters":"planar"}
For geoshape questions, you can also use the getValue expression to display the area of the polygon:
${polygon1 | getValue:"area":"hectares":"geodesic"}
The units and calculation method are optional parameters. The following units are accepted for length:
- feet
- kilometers
- meters
- miles
- nautical-miles
- yards
The following units are accepted for area:
- acres
- hectares
- square-miles
- square-kilometers
- square-meters
- square-feet
- square-yards
Alternatively, you can use any of the esriSRUnitType Constants or esriSRUnit2Type Constants supported by ArcGIS REST API. In your expression, use the numeric code for the constant without quotes, as follows:
${polyline1 | getValue:"length":109002:"geodesic"}
If no units are specified, the default is kilometers for length or square-kilometers for area.
The method can be either geodesic or planar. If no method is specified, geodesic is used by default.
Date, time, and date-time
To ensure that your date and date-time questions are presented in a way that's accurate to your region's formatting, you can use an expression to format the question to match a provided locale. Place the locale method first in an expression, and the locale code must be in lowercase.
${datetime | locale:"pt-br"}
Note:
For information on a specific language's locale code, see Wikipedia's List of ISO 639-1 codes. However, keep in mind that not all of these languages are supported by Survey123.
All date and date-time values in a feature layer are stored in coordinated universal time (UTC). By default, all date and date-time values returned in a report are in the same time zone as the web browser that requested the report generation. You can use the utcOffset method to alter the display of these values in a report to match a specific time zone. The following expression displays the response to a date-time question offset +1 hour from UTC:
${datetime | utcOffset:"+01:00"}
The utcOffset method supports the formats +01:00, +0100, and +01 and returns the same result. You can also use this method to alter the display of the response submission time. Be aware that utcOffset does not work with time questions.
For date and date-time questions, you can use an expression to format the date using DD, MM, and YYYY placeholders for day, month, and year, respectively. The following expression displays only the day and month, omitting the year:
${date | format:"DD/MM"}
You can also format the time in date-time questions, using HH, mm, and ss as placeholders for hours, minutes, and seconds, respectively. The following expression displays the day, month, hours, and minutes:
${datetime | format:"DD/MM HH:mm"}
You can display dates and times in the ISO 8601 format of YYYY-MM-DDTHH:mm:ss±HH:mm by leaving the value for the format method blank, as shown in the following example:
${datetime | format:""}
For more information on date and time formats, see the table below.
Note:
You must place the format method at the end of the expression.
You can print the date and time at which the report was generated using the $date keyword. Use the format method to control whether to print the date, the time, or both. The following syntax prints the date on which the report was generated (without the time) in the default date format for your locale:
${$date}
The following expression prints the month, day, year, hours, and minutes for the date and time at which the report was generated:
${$date | format:"MM/DD/YYYY HH:mm"}
The following expression prints the time at which the report was generated (without the date) in hours, minutes, and seconds in 12-hour time:
${$date | format:"h:mm:ss A"}
The $date keyword also supports the utcOffset and locale methods. The locale method is ignored when both format and locale are specified.
Date and time formats
The following table lists the most common placeholders that can be used with the format method to format dates and times in a report:
Placeholder | Description |
---|---|
YY | Last two digits of the year. Example: 2023 would be represented as 23. |
YYYY | Four digits of the year. Example: 2023 would be represented as 2023. |
M | Month number between 1 and 12. Example: January would be represented as 1. |
MM | Month number in two digits. Example: January would be represented as 01. |
MMM | Month in three letters. Example: January would be represented as Jan. |
MMMM | Month written in full. Example: January would be represented as January. |
D | Day number between 1 and 31. Example: The first day of the month is represented as 1. |
DD | Day number in two digits. Example: The first day of the month is represented as 01. |
Do | Day number that includes ordinal suffixes. Example: The first day of the month is represented as 1st. |
H | Hour number in 24-hour time. Example: 11 p.m. would be represented as 23. |
HH | Hour number in 24-hour time in two digits. Example: 2 a.m. would be represented as 02. |
h | Hour number in 12-hour time. Example: 11 p.m. would be represented as 11. |
hh | Hour number in 12-hour time in two digits. Example: 2 a.m. would be represented as 02. |
m | Minute number between 0 and 59. Example: 8 minutes would be represented as 8. |
mm | Minute number in two digits. Example: 8 minutes would be represented as 08. |
ss | Seconds number in two digits. Example: 9 seconds would be represented as 09. |
Z | Time zone offset in hours using separator. Examples: -07:00, +13:00 |
ZZ | Time zone offset in hours with no separator. Examples: -0700, +1300 |
x | Unix millisecond time stamp. Example: 9 p.m. on 4 May 2023 GMT would be represented as 1683234000000. |
X | Unix time stamp. Example: 9 p.m. on 4 May 2023 GMT would be represented as 1683234000. |
a | Lowercase morning or afternoon notation. Example: a.m. would be represented as am, and p.m. would be represented as pm. |
A | Uppercase morning or afternoon notation. Example: a.m. would be represented as AM, and p.m. would be represented as PM. |
Multiple choice
If a select one question is referred to in a placeholder by itself, for example, ${select_one}, it will return the choice label. If a select one question is used in an expression, or if the question uses an external select, a select one question will return the name of a choice item. The following example uses a choice name, rather than a label, for a conditional statement:
${if select_one=="choice1Name"}The user selected the first choice.${/}
To intentionally display the name of a choice rather than the label, use the getValue expression:
${select_one | getValue:""}
For both select one and select multiple questions, you can use an expression to place a check box next to a choice item, which is filled depending on the response to the question. The choice name—not the choice label—must be used. The following expressions would display selected fruits:
${select_one | checked:"apple"} Apple
${select_one | checked:"pear"} Pear
When Allow "Other" has been enabled for a select one or select multiple question, use the choice name of other:
${select_one | checked:"other"} Other fruits you like: ${favFruits_other}
Select multiple questions support expressions to output the total amount of choices selected, and to output a specific selected choice:
${select_multiple | countSelected}
${choiceQuestion1 | selectedAt:2}
Note:
The selectedAt expression begins counting selected choices at zero. This means that ${choiceQuestion1 | selectedAt:2} will return the third selected choice.
Select multiple questions also have a supported expression to return all selected choice items as a bulleted list, as follows:
${select_multiple | appearance:"bullets"}
Note:
If the label of your choice item contains double quotation marks, they must be preceded by a backward slash; otherwise, your report will not print. A backward slash is not necessary for single quotation marks. The following is an example:
${select_one | checked:"Service provided by \"Greg's Plumbing\""} Service provided by "Greg's Plumbing"
Repeats
To access questions in a repeat, add a repeat section to your template. For a repeat named defects, the ${#defects} placeholder denotes the start of the repeat section, while ${/} denotes the end. Placeholders pointing to questions in the repeat must be between the repeat section's start and end placeholders.
Note:
To print the contents of a repeat in a table, ensure that both the starting tag and the ending tag are placed inside the table or outside the table. A report can't be generated if one of these tags is inside a table while the other is outside it. In most cases, if a start tag and an end tag are placed inside a table, the start tag should be in the first cell and the end tag should be in the last cell.
To access questions in a nested repeat, place its tags between the tags for each repeat layer above the intended repeat section. The following is an example:
${#repeat1}
${#repeat2}
${#repeat3}
${field1InRepeat3}, ${repeat2.field1}, ${repeat1.field1}, ${mainLayer.field1}
${/}
${/}
${/}
Report expressions cannot read special characters, such as hyphens, when referencing layer names using the ${layername} syntax. When referencing a layer that contains a special character in its name, use an underscore in place of special characters. Alternatively, you can refer to the layer through the $layers keyword and either the layer name or layer ID, for example, ${$layers["my layer name"]} or ${$layers[0]}. This can be useful with duplicate layer names.
To reference a field in your repeat that has the same name as its parent repeat, use the full path syntax including both field name and repeat name, for example, ${sharedName.sharedName}.
To display the index of a repeat record, use the getValue expression with the reserved keyword $feature. This example will produce 1 for the first record in a repeat, 2 for the second, and so on:
${#defects}
${$feature | getValue: "position"}
${/}
Report queries
You can use aggregate functions to produce queries of the values in your printed responses. These queries are best suited to a summary section, which will only appear once in a report, regardless of the amount of responses printed. For more information, see Report queries.
To limit the printing of your report to a specific number of repeats, rather than every repeat associated with the response, use the resultRecordCount method to set a specific number of repeats to print:
${#defects | resultRecordCount:20}...${/}
You can use the orderByFields method to determine the order in which repeats will be printed. Declare a field name, followed by ASC or DESC, and the repeats will be printed according to that field's input in either ascending or descending order, respectively:
${#defects | orderByFields:"state_name ASC, pop2000 DESC"}...${/}
Conditional report elements
You can show or hide elements of a report conditionally using if statements. You can use the if statement by typing an expression in the starting ${if expression} placeholder, with ${/} denoting the end of the conditional segment. Some examples of if statements that you can use to show or hide parts of a report are the following:
- ${if photo1} displays the section only if the photo1 question has been answered.
- ${if integer1>0} displays the section only if the answer to the integer1 question is a positive number.
- ${if ((geopoint1 | getValue:"y")>0)} displays the section only if the geopoint is in the northern hemisphere.
- ${if multiple_choice1 | selected:"A"} displays the section only if the multiple choice question has had the choice 'A' selected.
- ${if (repeat1 | getValue:"count")>=3} displays the section only if repeat1 contains three or more records.
In the following example, the text in the second line will only appear in the report if high is selected for the priority select one question:
${if priority | selected:"high"}
High priority issues must be addressed within seven days.
${/}
To check whether a response contains a value for a question, only use an if statement referring to the field name directly with no other operators, for example, ${if photo1}. This format ensures that empty strings, null values, and undefined values are all considered empty values. This format applies to string, number, date, and attachment field types. When this format is used with repeats, the section will appear as long as there is at least one instance in the repeat.
To use conditional statements with date and time questions, perform calculations using Epoch time (milliseconds elapsed since January 1, 1970). For example, ${if (date1|getValue:"") < 1602735375000} displays the section only if the value in the date field is older than October 14, 2020. Be aware that report syntax doesn't have an equivalent to the XLSForm today() or now() functions, so it's impossible to compose a conditional statement for times relative to when the report was printed.
The following logical operators are supported in if statements:
Operator | Description |
---|---|
|| | True if one of two statements returns true |
&& | True if both given statements return true |
! | True if the statement is not true |
== | True if the two given values are equal to each other |
!= | True if the two given values are not equal to each other |
> | Evaluates whether the first value is greater than the second value |
>= | Evaluates whether the first value is greater than or equal to the second value |
< | Evaluates whether the first value is less than the second value |
<= | Evaluates whether the first value is less than or equal to the second value |
Limitations
The following limitations exist when using report templates:
- Filters applied to repeats in the Survey123 website will not be applied in reports. Repeats can only be filtered in a report using expressions.
- Your map will not appear in your report if the map is using a web map version earlier than 2.0, which was released in July 2014.
- Your map will not appear in your report if your ArcGIS Enterprise portal doesn't have a valid SSL certificate.
- Printing using report templates does not work with ArcGIS Enterprise deployments that aren't public facing. Attempting to do so will present a getaddrinfo ENOTFOUND error.
- Printing using report templates does not work with ArcGIS Enterprise deployments that use Integrated Windows Authentication (IWA).
- A maximum of 2,000 records can be included per report request.
- When the Survey123 website is installed on your infrastructure, the reporting API cannot be used. Reports can only be generated when using https://survey123.arcgis.com/.