Class
Survey123 web form options.
Properties
Property | Type | Notes |
---|---|---|
number | Enable auto-refresh the survey after submit successfully. You can set autoRefresh=3 which will refresh the survey after 3 seconds. | |
clientId inherited | string | A valid Client ID for your domain registered on ArcGIS for Developers website. |
container inherited | any | The HTML element that contains the web form, typically a DIV. |
any | Deprecated in version 3.14, use questionValue instead. | |
string | globalId parameter. Supported with version ≥ 3.9 | |
string[] | Elements can be set to be hidden, including navbar, theme, header, description, footer and submit. For example:
| |
host inherited | string | Pass the host URL on IE and Edge to send messages to the parent domain. |
instanceId inherited | string | to mark different webform instance in one page https://devtopia.esri.com/Beijing-R-D-Center/survey123-js-api/issues/62 |
boolean | Set this property to true and the web form will not send data to your feature service. | |
itemId inherited | string | The ItemId of the web form you want to load. |
jsApiVersion inherited | string | Set the version the Survey123 Web App JavaScript API. Set the value to 'latest' to use the latest version of the API. |
string | Sets the mode of the web form. Valid values are edit, which sets the survey to edit an existing entry rather than create one, and view, which opens an existing entry in read-only mode, and copy, which will create a new web form that is populated with the contents from an existing entry. When setting the mode, the globalId parameter (version ≥ 3.9) or objectId(version ≤ 3.9) parameter must also be provided. | |
string | objectId parameter. Supported with version ≤ 3.9 | |
OnFormLoaded | Invokes a callback function when the form is loaded. The callback parameters include:
| |
OnFormResized | Invokes a callback function when the form is resized. | |
OnFormSubmitted | Invokes a callback function when the form is submitted. For example:
| |
OnQuestionValueChanged | Invokes a callback function when the values in your form change. The callback parameters include:
| |
portalUrl inherited | string | The URL of your ArcGIS portal. If left empty, defaults to https://www.arcgis.com |
any | Allows you to set the question values on form loading. For example:
| |
token inherited | string | Required if you work with private surveys. |
version inherited | string | Version lock on a specific version. Specify 'latest' to always use the latest version of the web app, otherwise it will honor the version setting of the survey. For example:
|
number | Takes a number in pixels. Controls the width of the survey and a value smaller than 660 will be ignored. |
autoRefresh
autoRefresh: number
Enable auto-refresh the survey after submit successfully. You can set autoRefresh=3 which will refresh the survey after 3 seconds.
clientId
clientId: string
A valid Client ID for your domain registered on ArcGIS for Developers website.
container
container: any
The HTML element that contains the web form, typically a DIV.
defaultQuestionValue
defaultQuestionValue: any
Deprecated in version 3.14, use questionValue instead.
hideElements
hideElements: string[]
Elements can be set to be hidden, including navbar, theme, header, description, footer and submit. For example:
["navbar","header","description"]
You can also hide questions within your survey. For example:
['field: yourQuestionName']
host
host: string
Pass the host URL on IE and Edge to send messages to the parent domain.
instanceId
instanceId: string
to mark different webform instance in one page https://devtopia.esri.com/Beijing-R-D-Center/survey123-js-api/issues/62
isDisabledSubmitToFeatureService
isDisabledSubmitToFeatureService: boolean
Set this property to true and the web form will not send data to your feature service.
itemId
itemId: string
The ItemId of the web form you want to load.
jsApiVersion
jsApiVersion: string = "latest"
Set the version the Survey123 Web App JavaScript API. Set the value to 'latest' to use the latest version of the API.
mode
mode: string
Sets the mode of the web form. Valid values are edit, which sets the survey to edit an existing entry rather than create one, and view, which opens an existing entry in read-only mode, and copy, which will create a new web form that is populated with the contents from an existing entry. When setting the mode, the globalId parameter (version ≥ 3.9) or objectId(version ≤ 3.9) parameter must also be provided.
onFormLoaded
onFormLoaded: OnFormLoaded
Invokes a callback function when the form is loaded. The callback parameters include:
{
form: Form;
contentHeight: number;
webformVersion?: string;
}
onFormResized
onFormResized: OnFormResized
Invokes a callback function when the form is resized.
onFormSubmitted
onFormSubmitted: OnFormSubmitted
Invokes a callback function when the form is submitted. For example:
var webform = new Survey123WebForm({
clientId: "ABC1234567890",
container: "formDiv",
itemId: "",
onFormSubmitted: (data) => {
console.log('Form submitted: ', data.surveyFeatureSet);
}
});
Output example:
{
"features": [
{
"attributes": {
"what_is_your_name": "Jane",
"phone_number": 1,
"email": "jane@email.com",
"pick_up_location": {
"geometryType": "esriGeometryPoint",
"x": -105.18752574917914,
"y": 32.54681317350756,
"spatialReference": {
"wkid": 4326
}
},
"globalid": "{7F814C2C-42A7-47EA-8921-D748596C0105}",
"objectid": 2
},
"geometry": null,
"attachments": [],
"objectId": 2
}
],
"form": {
"layerName": "survey",
"portalUrl": "https://www.arcgis.com",
"header": {
"isVisible": true,
"content": "%3Cp%20style%3D%22text-align%3Astart%3B%22%20title%3D%22Event%20Registration%22%3EEvent%20Registration%3C%2Fp%3E"
},
"subHeader": {
"isVisible": true,
"content": "%3Cp%3EPlease%20add%20your%20contact%20information%3C%2Fp%3E"
},
"questions": [
{
"id": "field_1",
"position": 0,
"fieldName": "what_is_your_name",
"name": "what_is_your_name",
"type": "esriQuestionTypeText",
"label": "What is your name?",
"isRequired": false,
"fieldType": "esriFieldTypeString",
"validation": {
"valueRange": {
"isEnabled": false
},
"inputMask": {
"isEnabled": false,
"customFormat": ""
}
},
"fieldLength": 255
},
{
"id": "field_5",
"position": 1,
"fieldName": "phone_number",
"name": "phone_number",
"type": "esriQuestionTypeNumber",
"label": "Phone number",
"isRequired": false,
"fieldType": "esriFieldTypeDouble",
"validation": {
"valueRange": {
"isEnabled": false
},
"isInteger": false
}
},
{
"id": "field_2",
"position": 2,
"fieldName": "email",
"name": "email",
"type": "esriQuestionTypeEmail",
"label": "Email",
"isRequired": false,
"fieldType": "esriFieldTypeString",
"fieldLength": 255
},
{
"id": "field_4",
"position": 3,
"name": "pick_up_location",
"type": "esriQuestionTypeGeoPoint",
"label": "Pick-up location",
"isRequired": false,
"defaultValue": {
"spatialReference": {}
},
"fieldType": null,
"defaultExtent": {
"spatialReference": {
"wkid": 102100
},
"xmin": -46806367.14447204,
"ymin": -24890342.394552022,
"xmax": 46806367.14447204,
"ymax": 24890342.394552022
},
"isDeviceLocationRequired": false,
"maps": [
{
"type": "webmap",
"itemId": "2ea9c9cf54cb494187b03a5057d1a830",
"isDefault": true
}
],
"inputTools": [
"pin",
"search",
"locate"
],
"displayFormats": [
"DD"
]
}
],
"rules": [],
"version": "3.13",
"themes": [
{
"id": "49LEHetM6",
"name": "theme-custom",
"isEnabled": true,
"header": {
"backgroundColor": "#31872E",
"textColor": "#ffffff"
},
"form": {
"backgroundColor": "#ffffff",
"backgroundOpacity": 1,
"textColor": "#505050",
"primaryColor": "#31872E",
"primaryTextColor": "#ffffff",
"inputTextColor": "#505050",
"inputBackgroundColor": "#ffffff"
},
"webpage": {
"backgroundColor": "#B7DCC7"
}
}
],
"footer": {
"isVisible": true,
"content": ""
},
"submit": {
"buttonText": "Submit"
},
"settings": {
"thankYouScreenContent": "",
"openStatusInfo": {
"status": "open",
"schedule": {
"start": null,
"end": null
},
"closedStatusContent": ""
},
"recordStartEndTime": {
"isEnabled": false,
"fieldInfos": []
},
"notificationsInfo": {
"webhooks": []
},
"isVersionLocked": true,
"multiSubmissionInfo": {
"maxAllowed": 0,
"showSubmitAnotherTip": false
},
"draftInfo": {
"isEnabled": false
},
"instanceName": ""
}
}
}
onQuestionValueChanged
onQuestionValueChanged: OnQuestionValueChanged
Invokes a callback function when the values in your form change. The callback parameters include:
{
field: string; // question name
value: any; // answer for the question name
path?: string; // absolute path
repeatIndex?: number; // repeatIndex if the question is in a repeat
formId?: string; // feature layer id
}
portalUrl
portalUrl: string
The URL of your ArcGIS portal. If left empty, defaults to https://www.arcgis.com
questionValue
questionValue: any
Allows you to set the question values on form loading. For example:
{field_0: 'value1', field_1: 'value2'}
token
token: string
Required if you work with private surveys.
version
version: string
Version lock on a specific version. Specify 'latest' to always use the latest version of the web app, otherwise it will honor the version setting of the survey. For example:
version: 'latest'