Skip To Content

Add Report

  • URL:https://<reports-url>/add(POST only)
  • Required Capability:Administrator
  • Version Introduced:10.9

Description

This operation adds a report to the associated mission. A mission report is used by clients to submit relevant information to the mission and is represented in the portal by a Mission Report portal item and an associated hosted feature layer. The feature layer can be used by clients to submit new reports and to edit and view existing reports..

Request parameters

ParameterDetails
title

(Required)

String. The title of the report.

source

(Required)

Indicates the source submitting the reports. Set to user if a user will be submitting these reports, set to sensor if sensors will be used to submit reports instead.

If source is sensor sensorInfo is required.

description

(Optional)

String. A description of the report.

tags

(Optional)

A comma-separated list of strings. Used to add tags to the report.

questions

(Optional)

JSON Array. If an empty array is passed, the request is rejected. Used to represent the desired questions and their fields. Question types are based on Survey123 question type fields. See below for further details.

Available question types: Single Line Text, Single Choice, Number, Multiline Text, Dropdown, Button and Date/Time.

displayField

(Optional)

String. The name of the report feature layer's display field. Normally this is the field name of one of the report questions. If absent, the report feature layer's display field will be the first question's field name.

drawingInfo

(Optional)

JSON Object. Defines the report feature layer's drawing info, including a feature renderer. See drawingInfo for details.

locale

(Optional)

String. The locale used to generate the report. Must be a valid IETF BCP 47 language tag. Defaults to en

shareAsTemplate

(Optional)

Boolean. Shares the report as a template.

hasAttachments

(Optional)

Boolean. Enables attachments on the reports layer. Enable this to allow clients to upload images when submitting reports.

sensorInfo

(Required when source is sensor)

JSON Object. Defines the sensor that will generate the report. The sensor integration must be set to enabled, must contain a valid sensorId and at least one valid triggers property.

Example:

Example sensorInfo parameter:

{
	  sensorId: "Flic2",
	  triggers: ["double-press","single-press"]
	}

onReceiveAction

(Optional)

JSON Object. Defines the client action when a report is submitted.

Example:

{
		  "arcgisMissionManager": {
			"map": ["zoomToFeature", "showFeaturePopup", "animateFeatureSymbol"],
			"device": ["alert.mp4"] 
		  },
		  "arcgisMissionResponder": {
			"map": ["zoomToFeature"],
			"device": ["vibrate-3", "notification"]
		  }
		}

f

The response format. The default response format is html.

Values: html | json | pjson

Question Properties

Users answer questions while submitting reports. Use the questions parameter to define questions for a new report. Each question has the properties in the following table.

AttributeValue(s)
id

String. The desired id of the question.

position

Integer. The desired position within the questions fields you wish this question to appear.

fieldName

Required. String. The desired field name for the question in the feature layer.

name

String. The name of the question.

Example:


...
"name": "damage_level_dropdown",
"type": "esriQuestionTypeDropdown",
"label": "Pick one from this dropdown list",
...

type

Required. String. The question type.

Available types: esriQuestionTypeText, esriQuestionTypeTextArea, esriQuestionTypeSingleChoice, esriQuestionTypeDropdown, or esriQuestionTypeDateTime.

label

String. A user facing label for the question.

description

String. A description of the question.

isRequired

Boolean. Determines whether the question requires an answer when submitting a report.

defaultValue

The default value of the question when a user chooses to submit the report. The type of value provided should match the question's answer.

choices

Required when type is esriQuestionTypeSingleChoice or esriQuestionTypeDropdown

Contains a JSON Object items that contains an array of label, value, and position.

Example:


"choices": {
            "items": [
                {
                    "label": "This is option 1",
                    "value": "single_choice_1",
                    "position": 0
                },
                {
                    "label": "This is option 2",
                    "value": "single_choice_2",
                    "position": 1
                }
            ]
        }

Example User Report Request

Below is a sample request URL for the /addReport operation:


POST /webadaptor/rest/services/<mission_id>/MissionServer/addReport HTTP/1.1
Host: machine.domain.com
Content-Type: application/x-www-form-urlencoded
Content-Length: []

title=Damage Report
description=Use this report to document damage in the area
tags=Damage Report, Alpha, Bravo, Mission
questions=[
        {
            "isRequired": true,
            "fieldName": "damage_description",
            "defaultValue": "",
            "name": "multi_line_text",
            "description": "Multiline Text Field used to describe the damage",
            "id": "field_2",
            "position": 1,
            "label": "Describe the damage",
            "type": "esriQuestionTypeTextArea"
        },
        {
            "isRequired": false,
            "fieldName": "damage_level",
            "defaultValue": "single_choice_1",
            "name": "single_choice",
            "description": "Select a level of damage.",
            "id": "field_3",
            "position": 2,
            "label": "Label for selecting a level of damage",
            "type": "esriQuestionTypeSingleChoice",
            "choices": {"items": [
                {
                    "label": "This is option 1",
                    "position": 0,
                    "value": "single_choice_1"
                },
                {
                    "label": "This is option 2",
                    "position": 1,
                    "value": "single_choice_2"
                }
            ]}
        },
        {
            "isRequired": false,
            "fieldName": "date_time_occured",
            "name": "date_time",
            "description": "Select a Date and Time when the damage approx. occured",
            "id": "field_4",
            "position": 3,
            "label": "Date and Time damage occured",
            "type": "esriQuestionTypeDateTime"
        },
        {
            "isRequired": false,
            "fieldName": "team_reported",
            "defaultValue": "",
            "name": "dropdown",
            "description": "Select a team that reported the damage",
            "id": "field_5",
            "position": 4,
            "label": "Reported by team:",
            "type": "esriQuestionTypeDropdown",
            "choices": {"items": [
                {
                    "label": "Team Alpha",
                    "position": 0,
                    "value": "dropdown_choice_1"
                },
                {
                    "label": "Team Bravo",
                    "position": 1,
                    "value": "dropdown_choice_2"
                }
            ]}
        }
    ]
displayField=damage_level
drawingInfo={"renderer":{"type":"simple","symbol":{"color":[0,0,128,128],"size":15,"angle":0,"xoffset":0,"yoffset":0,"type":"esriSMS","style":"esriSMSCircle","outline":{"color":[0,0,128,255],"width":0.99975,"type":"esriSLS","style":"esriSLSSolid"}}}}
locale=en
hasAttachments=true
shareAsTemplate=true

Example Sensor Report Request

Below is a sample request URL for the reports/add operation:


POST /webadaptor/rest/services/<mission_id>/MissionServer/addReport HTTP/1.1
Host: machine.domain.com
Content-Type: application/x-www-form-urlencoded
Content-Length: []

title=Sensor Report
description=Use this for creating reports with sensors
tags=Sensor Report, Alpha, Bravo, Mission
questions=[
    {
        "id": "device_id",
        "position": 0,
        "fieldName": "single_line_text_1",
        "name": "single_line_text",
        "type": "esriQuestionTypeText",
        "label": "Device Id",
        "description": "",
        "isRequired": true,
        "defaultValue": "{deviceId}",
        "validation": {
            "valueRange": {
                "isEnabled": true,
                "min": 0,
                "max": 200
            }
        }
    },
    {
        "id": "location",
        "position": 1,
        "fieldName": "single_line_text_2",
        "name": "single_line_text",
        "type": "esriQuestionTypeText",
        "label": "Location",
        "description": "",
        "isRequired": true,
        "defaultValue": "{XY}",
        "validation": {
            "valueRange": {
                "isEnabled": true,
                "min": 0,
                "max": 200
            }
        }
    },
    {
        "id": "default_message",
        "position": 2,
        "fieldName": "single_line_text_3",
        "name": "single_line_text",
        "type": "esriQuestionTypeText",
        "label": "Message",
        "description": "",
        "isRequired": true,
        "defaultValue": "A sensor report has been submitted",
        "validation": {
            "valueRange": {
                "isEnabled": true,
                "min": 0,
                "max": 200
            }
        }
    },
    {
        "id": "user_fullname",
        "position": 3,
        "fieldName": "single_line_text_4",
        "name": "single_line_text",
        "type": "esriQuestionTypeText",
        "label": "Name of Sender",
        "description": "",
        "isRequired": true,
        "defaultValue": "{userFullname}",
        "validation": {
            "valueRange": {
                "isEnabled": true,
                "min": 0,
                "max": 200
            }
        }
    },
    {
        "id": "date",
        "position": 4,
        "fieldName": "date_time_5",
        "name": "date_time",
        "type": "esriQuestionTypeDateTime",
        "label": "Date and Time",
        "description": "Select a Date and Time",
        "isRequired": true,
        "defaultValue": "{dateNow}",
        "validation": {
            "valueRange": {
                "isEnabled": false
            }
        }
    }
]
drawingInfo={
    "transparency": 0,
    "labelingInfo": null,
    "renderer": {
        "type": "simple",
        "symbol": {
            "type": "esriSMS",
            "color": [
                255,
                76,
                25,
                255
            ],
            "angle": 0,
            "xoffset": 0,
            "yoffset": 0,
            "size": 12,
            "style": "esriSMSDiamond",
            "outline": {
                "type": "esriSLS",
                "color": [
                    0,
                    0,
                    0,
                    255
                ],
                "width": 0.375,
                "style": "esriSLSSolid"
            }
        }
    }
}
onReceiveAction={
    "arcgisMissionManager": {
        "map": [
            "zoomToFeature"
        ],
        "device": [
            {
                "type": "action",
                "name": "notification"
            },
            {
                "type": "sound",
                "name": "ring",
                "loop": false,
                "file": null
            }
        ]
    },
    "arcgisMissionResponder": {
        "map": [],
        "device": []
    }
}
f=json

JSON Response example


{
  "reportId": "a4d4228234af47978f787e75e7691498",
  "success": true,
  "templateId": "2fc4192579224368b2ac87d492392f66"
}