AddField
AddField(featureSet, fieldDefinition, fieldCalculator) -> FeatureSet
Adds a Field to a FeatureSet
Parameters
- featureSet: FeatureSet – The layer where the field will be added.
- fieldDefinition: Text | Dictionary – The field to add to the
FeatureSet. If aStringis provided, the field type will be indeterminate. If aDictionaryis provided, it should providename,nullable,type, and the optionalaliasproperties. - fieldCalculator: Text | Function – The SQL92 Expression to be used to calculate the field, or a user defined function
Examples
Add a Field. Returns a FeatureSet with a new field added.
var result = AddField(myLayer, "newField", "FID*10")
Add a Field with a definition. Returns a FeatureSet with a new field added, with a specific field definition.
var result = AddField(myLayer, { name: "newField", alias: "Friendly Name", type: "String", nullable: true}, "FID*10")
Add a Field using a function. Returns a FeatureSet with a new field added, with a specific field definition.
function calcArea(feat) { return Area(Geometry(feat)) }
var result = AddField(myLayer, "myArea", calcArea)
Aggregate
Aggregate(featureSet, groupByFields, fieldStats) -> FeatureSet
Returns a new FeatureSet where aggregates have been calculated. The aggregate fields are equivalent to the group by expression. The stats fields are the aggregates to calculate. No Geometry will be returned.
Parameters
- featureSet: FeatureSet – The layer to aggregate on.
- groupByFields: Array<Text> – An array of field names to group by.
- fieldStats: Array<Text> – An array of field statistics to calculate.
Examples
Aggregate on a Field, and calculate the Count. Returns a table where, for each type of fish, you have the Count of fish in the FeatureSet.
var result = Aggregate(myLayer, ["typeOfFish"], ["Count()", "numberOfFish"])
Aggregate on multiple fields, and calculate the Count, Sum, Min and Max values. Returns a FeatureSet containing the grouped aggregate results.
var result = Aggregate(myLayer, ["typeOfFish","subSpecies"], ["Count()", "numberOfFish", "Sum(remaining)", "numRemaining", "Min(legs)", "minLegs" , "numRemaining", "Max(arms)", "maxArms" ])
Aggregate on a Field, and calculate the Sum of an expression. Returns a table where, for each type of fish, you have the summed value from the FeatureSet.
var result = Aggregate(myLayer, ["typeOfFish"], ["Sum(field1 + field2)", "numberOfFishInAllBreedingGrounds"])
ApplicationProperty
ApplicationProperty(propertyName, discriminator?) -> *
Looks up an application property.
**Be aware that some properties returned by the function may only be accessible to an admin user.**
Parameters
- propertyName: Text – The name of a property of the application. One of the following values:
commits-waiting,distance-units,height-units,split-mode,reshape-mode,select-mode,append-mode,new-mode,area-units,webmap,token,organisation,user,theme,webmap-state,systeminfo,location-display-settings,location-capture-settings,app-state,active-template,item-info,theme-list,current-theme,is-in-edit-session,impact-zone,last-location,location-status,elevation-info,application-capability,height-units, orform-parameters. - discriminator (Optional): Text – A secondary discriminator for the property. For
elevation-info, pass"capture"to return active capture elevation information, or pass aFeatureSetto return elevation information for that layer when available. Forform-parameters, pass a form action title or id to return the current form values for that action, forapplication-capability, the discriminator is the name of the capability to check. For other properties this parameter is ignored.
Examples
Lookup number of commits waiting to save. Find out how many operations are waiting to be written to the database.
ApplicationProperty("commits-waiting")
Find out the distance units as a string.
ApplicationProperty("distance-units")
Find out the height units as a string.
ApplicationProperty("height-units")
Find out the area units as a string.
ApplicationProperty("area-units")
Find out the active split mode.
ApplicationProperty("split-mode")
Find out the active reshape mode.
ApplicationProperty("reshape-mode")
Find out the active select mode.
ApplicationProperty("select-mode")
Find out the active append mode.
ApplicationProperty("append-mode")
Find out the active new mode.
ApplicationProperty("new-mode")
Find out the webmap ID as a string.
ApplicationProperty("webmap")
Find out the access token for the app.
ApplicationProperty("token")
Returns the resource info from the portal.
ApplicationProperty("organisation")
Find the user info from the portal.
ApplicationProperty("user")
Find the current theme and its metadata for the application.
ApplicationProperty("theme")
Returns the state of the webmap.
ApplicationProperty("webmap-state")
Find out the AppRuntime info: software version, platform and whether the app is native or offline.
ApplicationProperty("systeminfo")
Current GPS display object with: currentGpsDisplay.showLocationOnMap: Shows the current GPS location on the map, currentGpsDisplay.showLocationAccuracy: Displays the GPS accuracy on the map as text, currentGpsDisplay.locationAutoPan: Flag to indicate if the map should be auto-panned to keep the location on the map.
ApplicationProperty("location-display-settings")
Current GPS capture settings as an object: currentGpsCaptureSettings.accuracy: Required accuracy in meters, currentGpsCaptureSettings.captureMode: Use capture averaging, currentGpsCaptureSettings.averagingPointCount: Number of points to capture averaging with.
ApplicationProperty("location-capture-settings")
Returns the current status of the location provider. Message is only set when additional information is available (e.g. error message)
ApplicationProperty("location-status")
returns {
status: 'stopped' | 'stopping' | 'starting' | 'started' | 'error',
message: 'failed to start'
}
Returns the last location received from the location provider (null if none received). gpsLocation contains standardised location information, gpsLocation.gpsDeviceData includes additional device / provider specific information. This property is not cleared. To detect a stale location, you can use a timestamp in gpsDeviceData combined with the location-status property.
ApplicationProperty("last-location")
returns {
locationData: {
gpsDeviceData: {/** Device / Provider Specific Data **/},
/** Standard Location Data **/
}
}
Find the state of the application. An object that includes current values for: dimensionMeasures, dpad, measure, rotation.
ApplicationProperty("app-state")
Find the active edit template.
ApplicationProperty("active-template")
Returns the application’s title, description, url, id, and displayTitle.
ApplicationProperty("item-info")
Will return the current list of available themes.
ApplicationProperty("theme-list")
Will return the current theme e.g.: {id: 'blue',name: 'Glacier'}.
ApplicationProperty("current-theme")
Returns elevation information. With one parameter it returns default elevation mode.
ApplicationProperty("elevation-info")
Returns active capture elevation information when capture mode is currently active.
ApplicationProperty("elevation-info", "capture")
Returns form parameter values for a form action by title or id.
ApplicationProperty("form-parameters", "my-form-action-title-or-id")
Returns the current maximum impact zone geometry when a running operation has a valid impact zone; otherwise returns null.
ApplicationProperty("impact-zone")
Returns a boolean value to show if the user is in edit session or not.
ApplicationProperty("is-in-edit-session")
Returns a boolean indicating whether a specific application capability is enabled.
ApplicationProperty("application-capability", "draw.freehand")
AssetTypeMetadata
AssetTypeMetadata(feat) -> Dictionary
Retrieve the asset type information for a network Feature.
Parameters
- feat: Feature – The
Featureto get asset information for
Examples
Get the name of the asset type of a Feature. Access the assetTypeName property of the returned metadata.
var assetTypeName = AssetTypeMetadata($feature).assetTypeName
AssociatedFeatures
AssociatedFeatures(feat) -> Dictionary
Retrieves all association records and the related features for a specific network Feature.
Parameters
- feat: Feature – The input
Featureto find all associations for
Examples
Retrieve the associations for a specific network Feature. Returns a Dictionary of association information.
var associations = AssociatedFeatures($feature)
CenterOn
CenterOn(geom, pt) -> Geometry
Takes a Geometry and centers it on another Point
Parameters
- geom: Geometry – The
Geometryto shift to anotherPoint - pt: Point – The
PointtheGeometryshould be centered on
Examples
Takes a Geometry and centers it on another Point
var newGeom = CenterOn(geometry, point)
Centroid
Centroid(geometry, keepNulls?) -> Point/FeatureSet
Returns the centroid of the input Geometry. If a FeatureSet is passed in, a new FeatureSet will be created with the centroid of each of the features.
Parameters
- geometry: Geometry/FeatureSet – The
Geometryfor which to calculate the centroid. - keepNulls (Optional): Boolean – Flag to indicate if null
Geometryshould be included in the resultFeatureSet.
Examples
Returns the centroid of the given Polygon.
Centroid(Geometry($feature))
Returns a FeatureSet with the centroid of each Feature.
Centroid(layer)
ChangeShape
ChangeShape(featureSet, changeFunction, keepNulls?, expectedType?) -> FeatureSet
Changes the shape of every Feature in a FeatureSet, using a function
Parameters
- featureSet: FeatureSet – The layer to update.
- changeFunction: Function – The user defined function to be called for each
Featurein theFeatureSet. - keepNulls (Optional): Boolean – Flag to indicate if null
Geometryshould be included in the resultFeatureSet. - expectedType (Optional): Text – The type of
Geometrythat is expected to be returned.Point,Polyline,Polygon,Multipoint,Extent
Examples
Rotate all features by 90 degrees. Returns a FeatureSet where all the features have been rotated
function rotateMe(feat) {
return Rotate(Geometry(feat),90)
}
var result = ChangeShape(myLayer, rotateMe)
Change a shape, but remove results that are null. Returns a FeatureSet where all the features have had centroid calculation. Lets the FeatureSet know that it will always be a Point.
function centroidMe(feat) {
return Centroid(Geometry(feat))
}
var result = ChangeShape(myLayer, centroidMe, false, "point")
ChangeShapeAndAttributes
ChangeShapeAndAttributes(featureSet, changeFunction, keepNulls?, expectedType?) -> FeatureSet
Changes the shape and attributes of every Feature in a FeatureSet, using a function
Parameters
- featureSet: FeatureSet – The layer to update.
- changeFunction: Function – The user defined function to be called for each
Featurein theFeatureSet. This should return a newFeature, from which the attribute andGeometrywill be copied across. If null is returned the originalFeaturewill be kept. Only the attributes listed in the newFeaturewill be replaced, the other attributes of the originalFeaturewill be preserved. - keepNulls (Optional): Boolean – Flag to indicate if null
Geometryshould be included in the resultFeatureSet. - expectedType (Optional): Text – The type of
Geometrythat is expected to be returned.Point,Polyline,Polygon,Multipoint,Extent
Examples
Rotate all features by 90 degrees. Returns a FeatureSet where all the features have been rotated and the rotateField has been changed to the value 10.
function rotateMeAndChangeField(feat) {
return Feature(Rotate(Geometry(feat),90), "rotateField", 10)
}
var result = ChangeShapeAndAttributes(myLayer, rotateMeAndChangeField)
CheckConnectivity
CheckConnectivity(checkExtent) -> Array<Dictionary>
Checks the connectivity in a region (based on the configured Sweet connectivity model)
Parameters
- checkExtent: Extent – The
Extentto check
Examples
Find all the Connectivity issues in a region.
CheckConnectivity($mapExtent)
Clone
Clone(value, deep?) -> Any
Clones an Arcade variable. Deep clones will also clone all the child values in Dictionary and arrays. Some types cannot be cloned (for example FeatureSet and FeatureSetCollection). A cloned Feature or Dictionary will not be immutable once cloned.
Parameters
- value: Any – The value to be cloned
- deep (Optional): Boolean – Flag to indicate if a deep clone is required. If true, all child objects will be cloned in an array or
Dictionary. A shallow clone will only clone the top-level object.
Examples
Clone a Trace configuration
var newConfig = Clone($traceConfig)
ClosestFacility
ClosestFacility(parameters, returnError) -> Dictionary
Run the closest facility sync task against a Network service. Will return a Dictionary containing the result.
Parameters
- parameters: Dictionary – The parameters for the closest facility call. Based on the ESRI JS API Route Task
- returnError: Boolean – Determines if the Arcade script will error, or return a
Dictionaryif the task fails.
Examples
Call the closest facility service. Returns the result from calling the closest facility service.
var result = ClosestFacility(myParameters, true)
return result;
Connections
Connections(feature) -> Dictionary
Finds all the Connections for a Feature, based on the Sweet connectivity model.
Parameters
- feature: Feature – The
Featureto find all connections for.
Examples
Get the connections of a Feature.
Connections($feature)
ConnectWebSocket
ConnectWebSocket(webSocketKey, url, messageActionName?) -> Boolean|Dictionary|Text
Opens a connection to a WebSocket. Return value will be true if successful or an error message if not.
Parameters
- webSocketKey: Text – A unique ID or key to identify the WebSocket connection in other scripts
- url: Text – The URL of the web socket to connect to
- messageActionName (Optional): Text – The name of the application Action to call when a message is received on the WebSocket or the socket status changes.
Examples
Connect to a WebSocket and send a message. Note that the Action to process messages must be defined elsewhere in the application.
ConnectWebSocket("exampleSocket", "wss://websocket.example.org", "HandleIncomingMessage");
if (GetWebSocketStatus("exampleSocket") == "connected") {
SendWebSocketMessage("exampleSocket", "Ping");
}
CreateAssociationRecord
CreateAssociationRecord(from, to, ruleType, contentVisibleOrPercentAlong?) -> Feature
Creates an association record Feature, that conforms to the fields of utility network associations table
Parameters
- from: Dictionary – The
Dictionaryshould contain the propertieslayerIdorlayerName,feature, and optionallyterminalIdorterminalName. - to: Dictionary – The
Dictionaryshould contain the propertieslayerIdorlayerName,feature, and optionallyterminalIdorterminalName. - ruleType: Number | Text – Allowed values are 1 | 2 | 3 | 4 | 5 | 6 |
junction-junction-connectivity|junction-junction|containment|attachment|junction-edge-from-connectivity|junction-edge-from|junction-edge-midspan-connectivity|junction-edge-midspan|junction-edge-to-connectivity|junction-edge-to - contentVisibleOrPercentAlong (Optional): Number | Boolean – If
ruleTypeiscontainment, then a boolean can be provided forisContentVisible. IfruleTypeisjunction-edge-midspan-connectivity(5), then this parameter can contain thepercentAlongvalue.
Examples
Create an attachment. Builds an attachment between two features
var associationRecord = CreateAssociationRecord({layerName:'Structure Junction', feature: fromFeature}, {layerName:'Communications Junction', feature: toFeature}, 'attachment')
Create a containment. Builds a containment association between two features
var associationRecord = CreateAssociationRecord({layerName:'Structure Junction', feature: fromFeature}, {layerName:'Communications Junction', feature: toFeature}, 'containment', true)
Create a Junction Junction connectivity. Builds a junction junction association between two features
var associationRecord = CreateAssociationRecord({layerName:'Communications Junction', feature: fromFeature, terminalId: 2}, {layerName:'Communications Junction', feature: toFeature, terminalId: 3}, 'junction-junction')
Create a Junction Edge Midspan connectivity. Builds a junction edge midspan association between two features
var associationRecord = CreateAssociationRecord({layerName:'Communications Edge Object', feature: fromFeature, terminalId: 2}, {layerName:'Communications Edge Object', feature: toFeature, terminalId: 3}, 'junction-edge-midspan', 0.5)
CreateFeature
CreateFeature(properties) -> Feature
Creates a Feature which conforms to the set of fields in a FeatureSet. Optionally a Feature template can be used to provide the default values.
Parameters
- properties: Dictionary – The
Dictionaryshould containlayerIdorlayerName, ageometryproperty containing theGeometry, and optionallytemplateName.
Examples
Builds a new Feature with Geometry and fields.
var newFeature = CreateFeature({layerName:'Trees', geometry: point})
Builds a new Feature with all the correct fields for a layer, using a template.
var newFeature = CreateFeature({layerName:'Trees', geometry: point, templateName: 'Birch'})
Crossings
Crossings(geomA, geomB) -> Array<Point>
Finds all the crossings between two Geometry objects.
Parameters
- geomA: Geometry – The
Geometryto check for crossings - geomB: Geometry – The second
Geometryto check for crossings
Examples
Find all the place two lines cross. Returns an array of points
var crossingPoints = Crossings(lineA, lineB)
Csv
Csv(featureSet, num?) -> FeatureSet
Converts a FeatureSet to a CSV String
Parameters
- featureSet: FeatureSet – The layer to be converted to a csv file
- num (Optional): Number – The max number of records to serialize. -1 will mean all records are put into the CSV file.
Examples
Convert layer to CSV. Converts the layer to a csv file
var result = Csv(myLayer)
Convert the top 10 records of a layer sorted by a specific field to CSV.
var result = Csv( OrderBy(myLayer, "fieldA ASC"),10);
CsvToLayer
CsvToLayer(sourceData, columns, geometryDefinition?) -> FeatureSet
Parses a CSV String into a FeatureSet.
Parameters
- sourceData: Text – A string containing the source CSV data.
- columns: Dictionary – A list of columns to convert to fields in the layer. The fields in the
Dictionaryshould bename,type– optionalString,Date,Integer,Number,Float,Long, orShort.dateFormatis an optional way of parsing aDatefield, andsourceNameis optional (a different field name to look up in the CSV). - geometryDefinition (Optional): Dictionary – Details of how to extract the
GeometryfromFieldin the CSV. Should be aDictionarywithxField,yFieldandspatialReference.
Examples
Read a CSV file into a layer. Returns a FeatureSet with the contents of the CSV file.
CsvToLayer(sourceData, [{"name": "field1", "type":"String"}, {"name": "field2", "type":"Date", "sourceName":"fieldNameInCsv", "format":"DD/MM/YYYY HH:mm"} ],{"xField":"x", "yField":"y", "spatialReference":{"wkid":102100}})
Difference
Difference(inputGeometry, subtractor, keepNulls?) -> Geometry|FeatureSet
Performs the topological difference operation for the two Geometry, or for each Feature in a FeatureSet. The resultant Geometry comes from inputGeometry, not the subtractor. The dimension of subtractor has to be equal to or greater than that of inputGeometry.
Parameters
- inputGeometry: Geometry | FeatureSet – The input
Geometryfrom which to subtract, or aFeatureSetwhere eachFeaturewill be individually used in the subtraction. - subtractor: Geometry | FeatureSet – The
Geometryto subtract frominputGeometry, or aFeatureSetwhere eachFeaturewill be individually used in the subtraction. - keepNulls (Optional): Boolean – Flag to indicate if null
Geometryshould be included in the resultFeatureSet.
Examples
Subtracts the given Polygon area from the Feature.
var subtractor = Polygon({ ... });
Difference(Geometry($feature), subtractor);
Subtracts the given Polygon from every Feature in a FeatureSet.
var subtractor = Polygon({ ... });
Difference(layer, subtractor);
Creates a FeatureSet where the Geometry is the Geometry minus the layer’s Geometry.
var geometry = Polygon({ ... });
Difference(geometry, layer);
DisconnectWebSocket
DisconnectWebSocket(webSocketKey) -> true|Text
Closes a connection to a WebSocket. Return value will be true if successful or an error message if not.
Parameters
- webSocketKey: Text – A unique ID or key to identify the WebSocket connection in other scripts
Examples
Disconnect from a WebSocket.
DisconnectWebSocket("exampleSocket");
Dissolve
Dissolve(featureSet, groupByFields, fieldStats) -> FeatureSet
Returns a new FeatureSet where aggregates have been calculated. The Geometry will be unioned together. The aggregate fields are equivalent to the group by expression. The stats fields, are the aggregates to calculate.
Parameters
- featureSet: FeatureSet – The layer to filter.
- groupByFields: Array<Text> – An array of field names to group by.
- fieldStats: Array – An array of field statistics to calculate.
Examples
Dissolve on a Field, and Calculate the Count. Returns a Table where for each type of fish, you have the Count of fish in the FeatureSet.
var result = Dissolve(myLayer, ["typeOfFish"], ["Count()", "numberOfFish"])
Dissolve on a Field, and Calculate, the Count, Sum, Min and Max Field. Returns a FeatureSet which has been filtered using a SQL92 expression.
var result = Dissolve(myLayer, ["typeOfFish","subSpecies"], ["Count()", "numberOfFish", "Sum(remaining)", "numRemaining", "Min(legs)", "minLegs" , "numRemaining", "Max(arms)", "maxArms" ])
Dissolve on a Field, and Calculate the Sum of an Expression. Returns a Table where for each type of fish, you have the Count of fish in the FeatureSet.
var result = Dissolve(myLayer, ["typeOfFish"], ["Sum(field1 + field2)", "numberOfFishInAllBreedingGrounds"])
EncodeHtmlAttribute
EncodeHtmlAttribute(value) -> Text
Encodes a String into a form that can be used as an HTML attribute.
Parameters
- value: Text – The
Stringto be encoded
Examples
Convert a String into an HTML attribute. Safely sanitises characters to safely add a string to HTML.
EncodeHtmlAttribute("value")
ExtentCachedFeatures
ExtentCachedFeatures(layer) -> FeatureSet
Speeds up script execution by caching the features in the current map Extent for this FeatureSet. As the Extent changes, this FeatureSet will be re-evaluated and the current set cached. Note that the maximum number of records that are returned from the cached FeatureSet is controlled by the maximum record count setting of the FeatureLayer (maxRecordCount).
Parameters
- layer: FeatureSet – The layer to cache in memory for the current viewing
Extent.
**Be aware that the layer variable should be set to an unfiltered map layer, otherwise performance will be significantly reduced.**
Examples
Optimise use of a layer on the map. Keeps the current map Extent in memory ready to be used for this layer.
ExtentCachedFeatures(FeatureSetByName($map, 'Sites of Interest'))
FeatureBuilder
FeatureBuilder(properties) -> Array<Feature>
Builds an Array of features given a number of properties
Parameters
- properties: Dictionary – The
Dictionaryshould contain the propertieslayerIdorlayerName,geometryfrom which to bulk create features,methoddescribing the approach taken to feature creation, and optionallytemplateName. The following methods are supported:multiple-point-features|point-at-start-of-line|point-at-end-of-line|point-at-every-vertex-of-line|point-at-every-vertex-of-line-except-end|point-at-every-vertex-of-line-except-start|point-at-every-vertex-of-line-except-start-and-end|multiple-single-part-lines|centroid|multiple-polygon-features|single-line-feature-boundary|point-at-start-of-polygon|point-at-every-vertex-of-polygon|point-at-every-vertex-of-polygon-except-start|buffer
Examples
Get a new PointFeature using multiple-point-features. This operation expects a Point Geometry to be used. It will create a new Feature initialised with the same Geometry.
var features = FeatureBuilder({method: 'multiple-point-features', geometry: point, layerName: 'Trees', templateName: 'Birch')
Get a new PointFeature using point-at-start-of-line. This operation gets a Feature from a Line. It can optionally take offset-distance, offset-side, distance-along, and distance-along-type options. distance-along-type should be proportional or distance.
var features = FeatureBuilder({method: 'point-at-start-of-line', geometry: myLine, layerName: 'Trees', templateName: 'Birch', 'offset-distance': 10, 'offset-side': 'left', 'distance-along': 10, 'distance-along-type':'distance')
Get a new PointFeature using point-at-end-of-line. This operation gets a Feature from a Line. It can optionally take offset-distance, offset-side, distance-along, and distance-along-type options. distance-along-type should be proportional or distance.
var features = FeatureBuilder({method: 'point-at-end-of-line', geometry: myLine, layerName: 'Trees', templateName: 'Birch', 'offset-distance': 10, 'offset-side': 'left', 'distance-along': 10, 'distance-along-type':'distance')
Get a new PointFeature using point-at-every-vertex-of-line. This operation gets a Feature from a Line. It can optionally take offset-distance, offset-side, distance-along, and distance-along-type options. distance-along-type should be proportional or distance.
var features = FeatureBuilder({method: 'point-at-every-vertex-of-line', geometry: myLine, layerName: 'Trees', templateName: 'Birch', 'offset-distance': 10, 'offset-side': 'left', 'distance-along': 10, 'distance-along-type':'distance')
Get a new PointFeature using point-at-every-vertex-of-line-except-end. This operation gets a Feature from a Line. It can optionally take offset-distance, offset-side, distance-along, and distance-along-type options. distance-along-type should be proportional or distance.
var features = FeatureBuilder({method: 'point-at-every-vertex-of-line-except-end', geometry: myLine, layerName: 'Trees', templateName: 'Birch', 'offset-distance': 10, 'offset-side': 'left', 'distance-along': 10, 'distance-along-type':'distance')
Get a new PointFeature using point-at-every-vertex-of-line-except-start. This operation gets a Feature from a Line. It can optionally take offset-distance, offset-side, distance-along, and distance-along-type options. distance-along-type should be proportional or distance.
var features = FeatureBuilder({method: 'point-at-every-vertex-of-line-except-start', geometry: myLine, layerName: 'Trees', templateName: 'Birch', 'offset-distance': 10, 'offset-side': 'left', 'distance-along': 10, 'distance-along-type':'distance')
Get a new PointFeature using point-at-every-vertex-of-line-except-start-and-end. This operation gets a Feature from a Line. It can optionally take offset-distance, offset-side, distance-along, and distance-along-type options. distance-along-type should be proportional or distance.
var features = FeatureBuilder({method: 'point-at-every-vertex-of-line-except-start-and-end', geometry: myLine, layerName: 'Trees', templateName: 'Birch', 'offset-distance': 10, 'offset-side': 'left', 'distance-along': 10, 'distance-along-type':'distance')
Get a new PointFeature at the centroid of a Geometry. This operation gets a new Feature at the centroid of a Polygon.
var features = FeatureBuilder({method: 'centroid', geometry: myPoly, layerName: 'Trees', templateName: 'Birch')
Get a new Polygon Feature using multiple-polygon-features. This operation expects a Polygon Geometry to be used. It will create a new Feature initialised with the same Geometry.
var features = FeatureBuilder({method: 'multiple-polygon-features', geometry: point, layerName: 'Boundaries', templateName: 'Site Boundary')
Get a new Polyline Feature using single-line-feature-boundary. This operation expects a Polygon Geometry to be used. It will create a new Feature initialised with a Line representing the boundary.
var features = FeatureBuilder({method: 'single-line-feature-boundary', geometry: point, layerName: 'Boundaries', templateName: 'Site')
Get a new PointFeature using point-at-start-of-polygon. This operation gets a Feature for the first vertex of a Polygon.
var features = FeatureBuilder({method: 'point-at-start-of-polygon', geometry: myLine, layerName: 'Trees', templateName: 'Birch')
Get new PointFeature values using point-at-every-vertex-of-polygon. This operation gets features for every vertex of a Polygon.
var features = FeatureBuilder({method: 'point-at-every-vertex-of-polygon', geometry: myLine, layerName: 'Trees', templateName: 'Birch')
Get new PointFeature values using point-at-every-vertex-of-polygon-except-start. This operation gets features for every vertex of a Polygon except the first Point.
var features = FeatureBuilder({method: 'point-at-every-vertex-of-polygon-except-start', geometry: myLine, layerName: 'Trees', templateName: 'Birch')
Get new features by buffering an existing Geometry using buffer. This operation gets a new Feature as a buffer of an existing one.
var features = FeatureBuilder({method: 'buffer', geometry: myLine, layerName: 'Trees', templateName: 'Birch', distance: 10)
FeatureCollection
FeatureCollection(definition) -> FeatureSet
DEPRECATED: Creates a FeatureSet from a FeatureCollection definition.
Parameters
- definition: Text | Dictionary – The
FeatureCollectionJSON. If aStringis used it will be parsed to find theFeatureCollectionelements.
Examples
FeatureCollection from a String. Returns a FeatureSet which iterates over the features in the FeatureCollection.
var featureSet = FeatureCollection("")
FeatureCollection from a Dictionary. Returns a FeatureSet which iterates over the features in the FeatureCollection.
var featureSet = FeatureCollection({})
FeatureLayer
FeatureLayer(url, credentials?, fieldList?) -> FeatureSet
DEPRECATED: Connects to a FeatureLayer, and returns the features as a FeatureSet.
Parameters
- url: Text – The URL of the layer, including the layer ID.
- credentials (Optional): Dictionary – The credentials to use to connect to the service. This should be based on a token.
- fieldList (Optional): Array<Text> – List of fields to fetch from the layer.
Examples
Connect to a public FeatureLayer. Returns a FeatureSet which iterates over all of the features.
var featureSet = FeatureLayer("//services.arcgis.com/.../FeatureServer/0")
Connect to a FeatureLayer with credentials. Returns a FeatureSet which iterates over all of the features.
var featureSet = FeatureLayer("//services.arcgis.com/.../FeatureServer/0", $useridentity)
Connect to a FeatureLayer limiting the fields returned. Returns a FeatureSet, with only the listed fields included.
var featureSet = FeatureLayer("//services.arcgis.com/.../FeatureServer/0", null, ["fieldA","fieldB"])
GdbVersion
GdbVersion(layer) -> Text
Finds the current gdb version for a layer
Parameters
- layer: FeatureSet – The
FeatureSetfor which to get the version
Examples
Find the gdb version. Finds the gdb version of a layer
var version = gdbVersion(layer)
GdbVersionCreate
GdbVersionCreate(urlOrLayer, name, description?, accessPermission?) -> Dictionary
Creates a new gdb Version.
Parameters
- urlOrLayer: Text | FeatureSet – The
urlof the VersionManagementServer, or aFeatureSetto derive this - name: Text – The name of the version to be created
- description (Optional): Text – A description for the version
- accessPermission (Optional): Text – The access permission. Default
private. Can beprivate|public|protected|hidden.
Examples
Create a gdb version. Makes a new version
var newVersionInfo = gdbVersionCreate(layer, 'newVersionName')
gdbVersionList
gdbVersionList(urlOrLayer, ownerFilter?, includeHidden?) -> Dictionary
Lists all the gdb versions that have been created
Parameters
- urlOrLayer: Text | FeatureSet – The URL of the VersionManagementServer, or a
FeatureSetto derive this - ownerFilter (Optional): Text – User id to use as a filter
- includeHidden (Optional): Boolean – Default false
Examples
List versions. List all versions
var newVersionInfo = gdbVersionList(layer)
Geocode
Geocode(search, fieldOrOptions?, options?) -> FeatureSet|Dictionary
Fetches the location for a String. If used with a FeatureSet and a Field, will geocode every address in a table.
Parameters
- search: Text | FeatureSet | Dictionary – The text to search (single line), or the
FeatureSetto geocode. If aDictionaryis provided, these will be considered as addressFieldvalues for the query. - fieldOrOptions (Optional): Text | Dictionary – If the first parameter is a
FeatureSet, then this parameter holds theFieldname or SQL expression which is to be used for the address query. If the first parameter is aStringorDictionary, this will hold thelocatoroptions. Seelocatoroptions below. - options (Optional): Dictionary – If the first parameter is a
FeatureSet, then this parameter holdslocatoroptions. This field can havecategories,countryCode,distance,outFields,locator: {url: …}, andkeepNulls.
Examples
Geocode an Address. Perform a simple geocode
Geocode('HP20 2QZ')
Geocode all features in a FeatureSet, throwing away any records that do not match
Geocode(myFeatureSet, 'field1', { keepNulls: false})
GetWebSocketStatus
GetWebSocketStatus(webSocketKey) -> connected|disconnected|connecting|errored
If a connection to a WebSocket is available in the running application, fetches the current status of that socket. Will return null if the socket is not registered.
Parameters
- webSocketKey: Text – A unique ID or key to identify the WebSocket connection
Gp
Gp(url, gpParameters, identity?, timing?, returnError?) -> Dictionary
Run a Geoprocessing Task. Will return a Dictionary containing the result.
Parameters
- url: Text – The
urlof the GP task - gpParameters: Dictionary – The parameters of the GP task
- identity (Optional): Identity – The identity to use when calling the GP task.
- timing (Optional): Number – The number of seconds to allow the GP task to run for, before erroring. Default is 5 minutes
- returnError (Optional): Boolean – Flag to indicate if an error object should be returned if the GP task fails. Default is false. If an error occurs, the returned
Dictionarywill have a field callederrorwith the message.
Examples
Call a GP task. returns a Viewshed result.
var result = Gp("https://sampleserver6.arcgisonline.com/arcgis/rest/services/Elevation/ESRI_Elevation_World/GPServer/Viewshed",
{
Input_Observation_Point: [Point({x:-6061190.600342937,y:3796137.309652354,spatialReference: {wkid: 102100}})],
Viewshed_Distance: { distance: 2000, units: "esriMeters" }
}, null);
return result;
Grid
Grid(bbox, size, origin?) -> FeatureSet
Generates a Layer with Grid Squares, that have been generated within a bounding box.
Parameters
- bbox: Polygon | Extent – An
Extentrepresenting the bounding box of the grid. If aPolygonis used, the squares are clipped to thePolygon, but the bounding box of thePolygonis used. - size: Number – The width and height of the grid square in meters
- origin (Optional): Point – An alternative origin for the grid squares to start at. Only grid squares that intersect the bounding box will be returned.
Examples
Generate a set of Grid Squares. Returns a FeatureSet.
Progress({"%grid%:buildinggrid": "Building Grid {{read}}"});
var grid = Grid(bbox, 5000);
GroundHeight
GroundHeight(point, options?) -> Number
Find the ground height for a Point.
Parameters
- point: Point – The
Pointat which to find the height - options (Optional): Dictionary – Options for how the ground is discovered. Use {inview: true} to use the views pre fetched data, otherwise the service will be queried
Examples
Query the ground elevation service and return the height
var height = GroundHeight(point)
Query the current ground data (in view already) to find the height.
var height = GroundHeight(point, {inview: true});
HasWebSocket
HasWebSocket(webSocketKey) -> Boolean
Checks if a connection to a WebSocket is available in the running application.
Parameters
- webSocketKey: Text – A unique ID or key to identify the WebSocket connection
Intersection
Intersection(geometry1, geometry2, keepNullsOrMatchFirstGeometry?) -> Geometry|FeatureSet|null
Constructs the set-theoretic intersection between two or more Geometry and returns a new Geometry, or if using a FeatureSet, will find the intersection for every Feature in the FeatureSet. For simple intersection between geometries the output type will follow the rules described [for the intersection operator](https://developers.arcgis.com/javascript/latest/references/core/geometry/operators/intersectionOperator/#execute).
Parameters
- geometry1: Geometry | FeatureSet – The
GeometryorFeatureSetto intersect withgeometry2. - geometry2: Geometry – The
Geometryto intersect withgeometry1. - keepNullsOrMatchFirstGeometry (Optional): Boolean – Flag to indicate if null shapes should be kept (when using
FeatureSet) or if only geometries matching the first geometry type should be returned (when using two geometries). Defaults totruein the first case, meaning nullGeometrywill be returned if there is no intersection andfalsein the second case, meaning geometries matching either geometry type will be returned.
Examples
Returns the area common to both polygons.
var geometry2 = Polygon({ ... });
Area(Intersection(Geometry($feature), geometry2), 'square-miles');
Find the intersection for every feature in a FeatureSet with a Geometry, but only return if it is not null.
var geometry2 = Polygon({ ... });
Intersection(layer, geometry2, false);
Kmeans
Kmeans(data, num, clusterIdentifier) -> Dictionary
Partition a dataset into a number of clusters based on their proximity using kMeans clustering.
Parameters
- data: FeatureSet – The set of data points to cluster.
- num: Number – The number of clusters to generate.
- clusterIdentifier: Text – A
Fieldname to be added to the data, to represent which cluster a feature belongs to.
Examples
Generate a cluster based on the input data.
Progress({"%kmeans%:readingdata": "Reading Customers {{read}}", "%kmeans%:solving": "Finding Clusters","%kmeans%:writing" : "Checking Clusters" });
var clusters = Kmeans(data, 5, "clusterId");
var centroids = clusters.centroids; // Array of Points
var dataWithClusterId = clusters.cursor; // Original data with clusterId appended as a Field
LookupUser
LookupUser(userId) -> Dictionary
Looks up a user in your Portal, based on their User ID
Parameters
- userId: Text – The userId that you wish to lookup.
Examples
Lookup a User in your Portal. Returns user information for the given user
LookupUser("rsmith")
MapLayer
MapLayer(map, title, id?) -> FeatureSet
DEPRECATED: Finds a layer in a Map and returns it as a FeatureSet
Parameters
- map: Map – A Map which contains a collection of layers. Each layer has an ID and Title
- title: Text – The title of the layer. The map layers will be searched and the appropriate layer returned.
- id (Optional): Text – The id of the layer. If title is not provided, the map layers will be searched for a layer with this id.
Examples
MapLayer by Title. Get a MapLayer using its title
var featureSet = MapLayer($map, "Cycle Hire")
MapLayer by ID. Get a MapLayer using its ID in the Map
var featureSet = MapLayer($map, "", "DemoLayerWM_1117")
PixelDistanceToMapUnit
PixelDistanceToMapUnit(distance?) -> Number
Gets a distance in pixel units and converts it to the map units
Parameters
- distance (Optional): Number – The number of pixels. Defaults to 1
Examples
Get a distance in map units. Calculate 10 pixels in map units
var currentValue = PixelDistanceToMapUnit(10)
PointAlongLine
PointAlongLine(line, distance) -> Point
Finds a Point, a given distance along a Line
Parameters
- line: Polyline – The
Polylinealong which to find thePoint - distance: Number – The distance along the
Polylinein meters
Examples
Finds the Point after 10m along a Line
var point = PointAlongLine(line, 10)
Progress
Progress(message) -> Null
Report Progress to the user. This function allows messages to be displayed in the calling Application, whilst the Arcade Script is running. This is useful for long running scripts where you wish to indicate in the Application what the script is doing.
Parameters
- message: Text | Dictionary – The
StringorDictionaryto send back to the user
Examples
Report Progress. Send a message to the calling application.
Progress("Fetching Data")
Report Progress from within a long running function. The regiongrow function can take some time, it will call progress regularly as it runs. The progress function is called before regiongrow to configure how it will report its progress.
Progress({"%regiongrow%:readingseeds": "Reading Seeds {{read}}", "%regiongrow%:readinggeog" : "Reading Geographies {{read}}", "%regiongrow%:growing" : "Generating Regions", "%regiongrow%:union" : "Merging Cells", "%regiongrow%:writing" : "Writing Regions" });
var regions = RegionGrow(seeds, geography);
Prompt
Prompt(title, message, okLabel?, cancelLabel?, alternateLabel?) -> true | false | null
Show a prompt box with ok, cancel, alternate buttons (cancel and alternate are optional). Will return true if the ok button is clicked, false for the cancel or null for close
Parameters
- title: Text – The title for the prompt
- message: Text – The message for the prompt
- okLabel (Optional): Text – The label for the ok button. Will default to
Yes - cancelLabel (Optional): Text – The label for the cancel button. Will default to
No. If null or ” is provided, the button will not be shown. - alternateLabel (Optional): Text – The label for the alternate button. Will default to null. If null or ” is provided, the button will not be shown.
Examples
Show a simple yes/no prompt.
var response = Prompt('Some title', 'Do you wish to continue');
RegionGrow
RegionGrow(seeds, referenceGeography) -> FeatureSet
Generates a Layer where polygons have been created around seedpoints, by merging neighbouring Geometry from a reference set.
Parameters
- seeds: FeatureSet – The set of seed points from which to grow regions from.
- referenceGeography: FeatureSet – The set of geographies to be used for creating regions. Neighbours will be merged around seed points.
Examples
Generate polygons around seed points. Returns a FeatureSet with the generated regions.
Progress({"%regiongrow%:readingseeds": "Reading Seeds {{read}}", "%regiongrow%:readinggeog" : "Reading Geographies {{read}}", "%regiongrow%:growing" : "Generating Regions", "%regiongrow%:union" : "Merging Cells", "%regiongrow%:writing" : "Writing Regions" });
var regions = RegionGrow(seeds, geography);
ReleaseEditLocks
ReleaseEditLocks(clearSelectionFirst?) -> Boolean
When using multi-user locking, remove any areas in the map that have been locked for editing and inform any connected applications. Locks cannot be released if there are active selected features. Will return true if the locks were released, false otherwise. Note: in normal operation there will be no need to use this function, multi-user locking and releasing will be handled automatically. This should only be used in specific circumstances, for example to release one geographical Extent before moving to another or when integrating the editor window using <iframe> or similar.
Parameters
- clearSelectionFirst (Optional): Boolean – If true clears any selections in the map before releasing locks. False by default.
Examples
Release edit locks while preserving current selections.
var released = ReleaseEditLocks();
return released;
Clear selections first, then release edit locks.
var released = ReleaseEditLocks(true);
return released;
RemoveField
RemoveField(featureSet, fieldName) -> FeatureSet
Removes a Field from a FeatureSet
Parameters
- featureSet: FeatureSet – The layer to filter.
- fieldName: Text – The
Fieldto remove
Examples
Remove the address Field. returns a FeatureSet which has the address field removed
var result = RemoveField(myLayer, "address")
ReverseGeocode
ReverseGeocode(search, fieldOrOptions?, options?) -> FeatureSet|Dictionary
Reverse geocodes a Point, or all the records in a FeatureSet.
Parameters
- search: Point | FeatureSet – The
Pointor set of features to reverse geocode. - fieldOrOptions (Optional): Text | Dictionary – If the first parameter is a
FeatureSet, then this parameter holds theFieldname to be added to theFeatureSet. If the first parameter is aPoint, this holds the locator options. - options (Optional): Dictionary – If the first parameter is a
FeatureSet, then this parameter holds locator options. This field can havecategories,countryCode,distance, andlocator: {url ...}.
Examples
Reverse Geocode a Point. Perform a simple reverse geocode
ReverseGeocode(Point({x:-6061190.600342937,y:3796137.309652354,spatialReference: {wkid: 102100}}))
Reverse geocode all features in a FeatureSet.
ReverseGeocode(myFeatureSet, 'address')
Route
Route(parameters, returnError) -> Dictionary
Run the route sync task against a Network service. Will return a Dictionary containing the result.
Parameters
- parameters: Dictionary – The parameters for the route call. Based on the ESRI JS API Route Task
- returnError: Boolean – Determines if the arcade script will error, or return a
Dictionaryif the service area task fails.
Examples
Call network service route. returns the result from calling the route service
var result = Route(myParameters, true)
return result;
SendWebSocketMessage
SendWebSocketMessage(webSocketKey, message) -> Boolean|Text
Sends a message to an open WebSocket connection. Return value will be true if successful or an error message if not.
Parameters
- webSocketKey: Text – A unique ID or key to identify the WebSocket connection in other scripts
- message: Any – The message to send to the web socket (typically a
Stringbut could be binary data)
Examples
Connect to a WebSocket and send a message. Note that the Action to process messages must be defined elsewhere in the application.
ConnectWebSocket("exampleSocket", "wss://websocket.example.org", "HandleIncomingMessage");
SendWebSocketMessage("exampleSocket", "Ping");
ServiceArea
ServiceArea(parameters, returnError) -> Dictionary
Run the solveServiceArea geoprocessing task against a Network. Will return a Dictionary containing the result.
Parameters
- parameters: Dictionary – The parameters for the serviceArea call. Based on the ESRI JS API Service Area Task
- returnError: Boolean – Determines if the arcade script will error, or return a
Dictionaryif the service area task fails.
Examples
Call solveServiceArea geoprocessing task.
var result = ServiceArea(myParameters, true)
return result;
SimplifyOGC
SimplifyOGC(geometry) -> Geometry
Returns the simplified Geometry of the input Geometry according to OGC standards. The OGC standard defines a simplified Geometry as one that has no self-intersections and is topologically valid ([OGC Simple Feature Access specification 1.2.1](https://www.ogc.org/standards/sfa/)). This uses stricter rules than [Simplify](https://developers.arcgis.com/arcade/function-reference/geometry_functions/#simplify).
Parameters
- geometry: Geometry – The
Geometryfor which to calculate the simplifiedGeometry.
Examples
Returns the simplified Geometry of the given Polygon according to OGC standards.
SimplifyOGC(Geometry($feature))
State
State(key, value?, semantics?) -> Any
Stores and sets State that can be used across scripts
Parameters
- key: Text – The key of the
State. This will be used to save or fetch theState - value (Optional): Any – The value to be stored in State. This must be a simple type, such as
String,Number,Date,Geometry,Dictionary,Array. It cannot contain aFeatureSet - semantics (Optional): Dictionary – This is a
Dictionarywhich can provide meta data about how long a value should be stored inState. For example{type:'operation'}, will only keep theStatefor the duration of the executing operation.{type:'time', timeout: 1000}, will only keep theStatefor 1000 milliseconds.
Examples
Get a value from State.
var currentValue = State('keyA')
Set a value in State.
State('keyA', 'someValue')
SymbolFromFeature
SymbolFromFeature(feat, layer, format?) -> Dictionary|Text
Provided with a layer and Feature, the function will return an ArcGIS REST-based symbol.
Parameters
- feat: Feature – The
Featureto get the symbol for - layer: Dictionary – A
Dictionarywhich references a layer, by providing alayernameorlayerid - format (Optional): Text – The
formatto return the symbol in. Values can be'text'or'dictionary'. Defaults to'text'.
Examples
Get the symbol definition for a Feature in a layer.
var symbol = SymbolFromFeature(feat, { layername:'Trees'})
SymmetricDifference
SymmetricDifference(leftGeometry, rightGeometry, keepNulls?) -> Geometry
Performs the symmetric difference operation on two geometries, or for each Feature in a FeatureSet. The symmetric difference includes the parts of both geometries that are not common with each other.
Parameters
- leftGeometry: Geometry | FeatureSet – The
Geometryinstance to compare torightGeometryin the XOR operation, or aFeatureSetwhere eachFeaturewill be individually used in the XOR operation. - rightGeometry: Geometry | FeatureSet – The
Geometryinstance to compare toleftGeometryin the XOR operation, or aFeatureSetwhere eachFeaturewill be individually used in the XOR operation. - keepNulls (Optional): Boolean – Flag to indicate if null
Geometryshould be included in the resultFeatureSet.
Examples
Returns a Polygon representing areas where both inputs do not overlap.
var geometry2 = Polygon({ ... });
SymmetricDifference(Geometry($feature), geometry2);
Returns a FeatureSet where each Feature has been XORed with the input Geometry.
var geometry2 = Polygon({ ... });
SymmetricDifference(layer, geometry2);
Returns a FeatureSet where the input Geometry has been XORed with each Feature in the FeatureSet, to create a new FeatureSet.
var geometry2 = Polygon({ ... });
SymmetricDifference(geometry2, layer);
ToScreenPoint
ToScreenPoint(pt) -> Dictionary
Converts a map Point into screen coordinates
Parameters
- pt: Point – The
Pointto be converted to screen coordinates
Examples
Find the screen Point. Returns a Dictionary with x and y in screen coordinates
var screenPoint = ToScreenPoint(point);
Console(screenPoint.x + ',' + screenPoint.y)
UnfilteredFeatureSet
UnfilteredFeatureSet(featureSet, removeWebMapFilter) -> FeatureSet
Unfilters a FeatureSet by removing the layer filter set in the builder (and optionally the layer filter set in the webmap).
Parameters
- featureSet: FeatureSet – The layer to unfilter.
- removeWebMapFilter: Boolean – If set to true, layer filters in the webmap and builder are both removed. If set to false, only the layer filter in builder is removed.
Examples
Unfilter to just the service. Gets a FeatureSet based on the raw service.
var featureSet = UnfilteredFeatureSet(fs, true)
Unfilter to just the webmap’s original filter. Get a FeatureSet as originally setup in the webmap.
var featureSet = UnfilteredFeatureSet(fs,false)
Union
Union(geometries) -> Geometry
Constructs the set-theoretic union of the Geometry in the input array or a FeatureSet and returns a single Geometry. All inputs must have the same Geometry type and share the same SpatialReference.
Parameters
- geometries: Array<Geometry> | FeatureSet – An array of
Geometryto union into a singleGeometry, or aFeatureSet.
Examples
Returns a single Polygon representing the union of both inputs.
var geometry2 = Polygon({ ... });
Union([ Geometry($feature), geometry2 ]);
Returns a single Polygon for all the features in a FeatureSet.
Union(myFeatureSet);
UtilityNetworkLayers
UtilityNetworkLayers() -> Array<Dictionary>
This function returns an array containing the metadata for the utility network layers in the current map.
Examples
Retrieve a collection of utility network layers in the current map. Returns an array of dictionaries containing metadata for layers. Each Dictionary includes the following properties: layertitle, layerid, networksourceid, isstructurenetwork, and featureclassusagetype.
var mapUtilityLayers = UtilityNetworkLayers()
UtilityNetworkMetadata
UtilityNetworkMetadata() -> Dictionary
This function returns a Dictionary that includes the metadata information about the utility network service currently being used in the application.
Examples
Get the metadata for the current utility network.
var utilityNetworkMetadata = UtilityNetworkMetadata()
UtilityNetworkSelectedFeatures
UtilityNetworkSelectedFeatures() -> Array<Text>
Creates a list of the global IDs for all selected utility network features in the current selection
Examples
Retrieve a collection of utility network features that have been selected. Returns an array of the globalId field values for every selected feature in the utility network.
var selectedUtilityNetworkFeatures = UtilityNetworkSelectedFeatures()
Voronoi
Voronoi(seeds, bbox?) -> FeatureSet
Generates a Voronoi set of polygons, given a layer of seed points, and a bounding box.
Parameters
- seeds: FeatureSet – A layer containing points, which are to be used as the seeds for the Voronoi.
- bbox (Optional): Extent | Polygon – The bounding box for the polygons. If a
Polygonis used, the voronoi will use the bounding box of thePolygon, but then the resulting polygons will be clipped to the originalGeometry.
Examples
Generate a set of Voronoi Polygons. Returns a FeatureSet with polygons for all the seed points.
Progress({"%voronoi%:readingdata": "Reading Sales Team {{read}}","%voronoi%:calculating" : "Generating Territories","%voronoi%:writing" : "Writing Territories" })
var voronoiRegions = Voronoi(seeds, Extent(allBoundary));
Wait
Wait(delayInMilliseconds) -> Boolean
Forces the script execution to wait for a period of milliseconds
Parameters
- delayInMilliseconds: Number – Number of milliseconds to wait
Examples
Wait for a second.
Wait(1000)
WaitForCommits
WaitForCommits() -> Boolean
Forces Sweet to pause execution until the commit queue is empty. Ensures the server has the same contents as the app. This function should be used at the beginning of a script to ensure all changes are on the server, before new filters are applied to layers, or the map is reset.
Examples
Wait until the commits stack is empty. Pause the app, until the commits are finished.
WaitForCommits()
Webhook
Webhook(url, query?, form?, sendFormat?, responseFormat?) -> Dictionary|Text
Calls an external URL, and returns the result
Parameters
- url: Text – The url of the Webhook
- query (Optional): Dictionary – The parameters to pass in the URL querystring. The default is null. If this value exceeds the length allowed for a URL, the request will be converted to a POST request (if no form parameter is provided)
- form (Optional): Dictionary | Text – The content to pass in the body of the request. If this parameter is provided, the request will be sent as a POST request. If a
Dictionaryis provided, it will be encoded as application/x-www-form-urlencoded, unless overridden by thesendFormatparameter. If a string is provided, it will be placed in the body with no encoding. The default is null. - sendFormat (Optional): Text –
bodyorform. The default isform. This overrides how theformparameter is encoded. If the value isbody, the contents of the form parameter will be converted to a string and sent as the body. Otherwise the form parameter is expected to be aDictionarythat is sent as a POST request encoded as application/x-www-form-urlencoded. - responseFormat (Optional): Text –
textorjson. The default isjson
Examples
Get a next sequence value. Creates a row in an online table, gets its object ID and then deletes it.
var result = Webhook('https://.../FeatureServer/0/addFeatures',
{ f: 'json' },
{ "features": [Feature(null, "name", "A")] })
var objectId = result.addResults[0].objectId
var result = Webhook('https://.../FeatureServer/0/deleteFeatures',
{ f: 'json' }, { "objectIds": objectId });
return objectId
WorkflowManager
WorkflowManager(url, identity, actionName, actionParameters) -> *
Performs an operation in Workflow Manager
Parameters
- url: Text – The url of the Workflow Manager.
- identity: Identity – The identity to use when calling Workflow Manager
- actionName: Text – The name of the action to perform. One of the following values:
create-job,create-hold,reopen-job,close-job,delete-job,list-job-activity,log-job-activity,unassign-job,update-job,assign-job,get-job,get-job-notes,update-job-notes,send-notification,extended-properties-add-record,extended-properties-delete-record,extended-properties-update-record,extended-properties,get-steps,get-step,step-canrun,step-log-comment,assign-steps,step-movenext,step-comments,get-current-step,steps-markasdone,steps-execute,user,steps-assign. - actionParameters: Dictionary – The parameters of the action. See the Workflow Manager documentation for expected values.
Examples
Get the details of a Job. Queries Workflow Manager and gets a job.
WorkflowManager('//..../WMServer', $userIdentity, 'get-job', { jobid: '3833-38383' })
