Prepopulate answers

You can prepopulate answers in Survey123 in a number of ways.

Default answers

You can set default answers for survey questions in the default column of your spreadsheet when you're designing your survey. This prepopulates your survey question with the same answer every time you begin a survey or when a question becomes relevant. This is especially useful when the answer to your survey question will be the same the majority of the time. You can still edit the default answer if necessary, but setting the default answer can save you time when completing your surveys. Default answers can contain constants such as strings and numbers.

Answers to select_multiple questions work differently than others, with each checked answer entered in the order it was selected, separated by commas. To define several values as defaults in a select_multiple field, separate them with commas, for example, item1,item2,item3.

Geopoint, geotrace, and geoshape questions support default answers. For more information about setting a default, see Geopoints and Geotrace and geoshape.

Calculations

Calculations are similar to defaults, but there are differences. Unlike the default column, which is evaluated only when the survey is opened or the question becomes relevant, calculations are evaluated every time answers in your survey that are inputs to the calculation change or become relevant. Calculations can use existing answers in your form. For example, the expression 100 - (${integer1} + ${integer2}) entered in the calculation column of a question sums the values of questions integer1 and integer2, subtracts that value from 100, and sets that value as your answer. The user can overwrite that value, but the calculation can provide a starting answer to guide the user.

Tip:

If the result of a calculation is manually edited, you can use the button that appears to erase the edited value and run the calculation again.

Calculation mode

The calculationMode parameter entered in the bind::esri:parameters column controls when calculations in questions are calculated, for example, calculationMode=manual. There are four supported values:

  • auto—Calculate when the question is empty or has not been previously modified by the user. If no value is provided, this is the default calculation behavior.
  • manual—The question will only calculate when the Calculate button next to the question is pressed.
  • always—Calculate when any value referenced in the calculation expression changes. This includes dynamic functions, such as now().
  • whenEmpty—Calculate until a nonempty value is returned. Once a nonempty value is returned, the question behaves in the same way as the manual mode. Calculations that contain dynamic functions, such as now(), will not recalculate unless the Calculate button is pressed. The whenEmpty mode is useful when you do not want a question that has already been calculated with a nonempty value to update when the form is reloaded, for example, when opening from the Inbox.

The following question types support the calculationMode parameter:

  • text
  • decimal
  • integer
  • note
  • date
  • time
  • dateTime
  • select_one
  • select_multiple
  • geopoint
  • calculate
  • hidden

Note:

The calculationMode parameter is not supported by the Survey123 web app.

Device and user properties

The pulldata("@property") function allows you to extract information about the devices from which survey responses are submitted, and the signed-in users who submit these responses. This function is useful for recording technical details and information about the context in which your survey was taken.

The function returns a device or user property using the format pulldata("@property", '<property name>'). The following example returns the UTC offset of the device, allowing users to record the time zone in which the survey was taken:

pulldata("@property", 'utcOffset')

The pulldata("@property") function can be used to detect the way the user is currently interacting with their survey response using the following:

pulldata("@property", 'mode')

The mode property has three possible values, returning new if the user is producing a new survey response (including one copied from an existing survey), returning edit if the user is editing an existing response, and returning view if the user is viewing an existing response in read-only mode. The following example, when placed in the readonly column, detects whether the user is editing an existing response and prevents them from editing the chosen question:

pulldata("@property", 'mode') = 'edit'

The pulldata("@property") function can also be used to determine where a survey was opened. The following example determines whether the survey was opened from the inbox:

pulldata("@property", 'status') = 'inbox'

Caution:

It is recommended that you do not store the results of the mode or status properties in a hidden or calculate question and do not enable or disable questions using these properties in the relevant column. Doing so may cause deletion of the contents of these fields or values to not update as expected.

The pulldata("@property") function supports the following properties:

PropertyDescription

pulldata("@property", 'portalUrl')

The URL of the portal to which the survey is submitted.

pulldata("@property", 'token')

The token passed to the feature layer.

pulldata("@property", 'portalInfo')

All portal information, as a JSON object.

pulldata("@property", 'online')

A Boolean value. The value is true if the device has network activity; otherwise, it's false.

pulldata("@property", 'utcOffset')

Offset in hours from UTC for the local time zone.

pulldata("@property", 'language')

Language used in the current survey.

pulldata("@property", 'locale')¹

The Locale object used in the current survey.

pulldata("@property", 'localeInfo')¹

The AppStudio LocaleInfo object used in the current survey containing the language code in various notations.

pulldata("@property", 'timeZone')

Time zone code.

pulldata("@property", 'username')

ArcGIS organizational account username of the currently signed-in user.

pulldata("@property", 'email')

ArcGIS organizational account email address of the currently signed-in user.

pulldata("@property", 'userFullName')

First and last name of the currently signed-in user.

pulldata("@property", 'userFirstName')²

First name of the currently signed-in user.

pulldata("@property", 'userLastName')²

Last name of the currently signed-in user.

pulldata("@property", 'deviceId')³

Unique ID generated by Survey123 representing the specific device on which the survey was taken. This is distinct from a mobile device's International Mobile Equipment Identity (IMEI), as Survey123 runs on devices that may not have an IMEI.

pulldata("@property", 'deviceModel')³

Model name of the user's device.

pulldata("@property", 'OS')³

Operating system name of the user's device.

pulldata("@property", 'appVersion')

Version number of the field app, or build number of the web app.

pulldata("@property", 'surveyName')

Name of the survey.

pulldata("@property", 'userAgent')

User agent string for the user's device.

pulldata("@property", 'mode')

Returns new if the user is creating a survey response, edit if the user is editing an existing response, or view if the user is viewing a response in read-only mode.

pulldata("@property", 'status')

Returns draft, submitted, sent, or inbox if the survey was opened from Drafts, Outbox, Sent, or Inbox, respectively. An empty string is returned if the response is new.

¹For use with the pulldata("@javascript") function only.

²These parameters are dependent on what is present in the identity provider's configuration and may not be available in organizations that use authentication other than built-in authentication.

³The Survey123 field app only.

Favorite answers

After you've entered answers into the Survey123 field app, you can save them to use in subsequent surveys by setting your favorite answers. Using the menu in the upper right corner, you can set the current state of your survey to act as your favorite answers.

Once you've set your favorite answers, you can insert them into new surveys by opening the menu and clicking Paste answers from favorite.

If at any time you need to change your favorite answers, enter them into your current survey and click Set as favorite answers. If you enter repetitive information in a field, you can use your current answers to prepopulate subsequent surveys. The survey that you use to set your favorite answers is marked with a star.

Note:

If the Sent folder has been disabled, you cannot use a sent survey for favorite answers. In this case, saving your survey with favorite answers as a draft allows the Paste answers from favorite option to work.

CSV data

Populating answers with information that you have stored on your device can minimize the time it takes to complete your survey. The information can be data collected from a previous survey or can provide multiple answers based on the user's entry of a single answer.

Prepopulating answers is useful in asset inspection surveys. By entering an asset ID number (by typing it or scanning a barcode), details of that asset can be retrieved from the .csv file and used to answer other questions such as location, last inspection date, and condition at the time of the last inspection.

For additional details on how to populate answers in this way, see Retrieve a value from CSV.

Note:

If your .csv file lacks a column header, or has a trailing comma at the end of the file's rows, the .csv file will fail to import into the survey.