The multi layer add, delete, and modify task allows records to be inserted into multiple different layers in the web map. This function provides the most flexible approach to updating any data in the application.

The data script for the task is expected to return a set of changes for each layer of interest. The changes will be worked through in order.

The data changes should be returned as an array:

return { changes: [
            {
              layerTitle: "name of layer",
              // layerid: "id of layer" // Alternative 
              insert: <list of features to insert>,
              update: <features to update>
              delete: <features to delete>
            }
        ]  
        //, crackandcluster: true // Optional to cause cracking
        // and clustering to occur as a final stage to the operation
} 

The structure for insert, update and delete is the same as for the Add, delete, modify records task:

insert

This should be an array of feature items.

delete

This can be a FeatureSet derived (as a filter or spatial filter) from $targetLayer. Alternatively it can be an array of features (initially derived from $targetlayer, or a list of object ids).

modify

This can be a FeatureSet derived from the ChangeShapeAndAttributes, or more easily an array of change items. A change item references a feature or an object id and provides a set of attributes to change and/or an updated geometry.

The examples below illustrate how to use the return dictionary.

Example data scripts

Failing the whole operation

return {
  error: "Cannot add as items already exist"
};