Sweet provides a number of commands that can be used in Sweet run-action tasks.
Commands
add-reference-layer
Add a reference layer to the map.
Parameters
- uniqueid: Text [optional] — The unique ID of the incoming reference layer.
- url: Text [optional] — The URL of the incoming reference layer. If this not set, the
portalitemidmust be set. - portalitemid: Text [optional/required] — The Portal Item ID of the incoming reference layer. Optional if
urlis populated; otherwise required. - layerid: Text [optional/required] — If
portalitemidis a feature set, provide the layer ID within that set. Optional ifportalitemidpoints to a feature layer. - referenceLayerID: Text [optional] — Reference an existing layer by ID to determine placement. Default is top of the layer list.
- newLayerPosition: Text [optional] — Specify
"above"or"below"the existing layer. - data: Dictionary [optional] — Specify an uploaded file object (e.g.,
$action.myfile) when adding a reference layer. - layer-name: Text [optional] — Name of the layer in the uploaded file.
- layer-id: Text [optional] — ID of the layer in the uploaded file.
- urltype: Text [optional] — Type of URL (
"wmts-url"|"wms-url"|"csv-url"|"wfs-url"|"kml-url"|"geojson-url"). Defaults to map, image, or feature service URL if not provided.
Example
return {
command: "add-reference-layer",
// uniqueid: "",
url: "//....",
// data: $action.myfile
// layer-name: "",
// layer-id: "ABCD"
portalitemid: "...",
layerid: "",
referenceLayerID: "",
newLayerPosition: "below"
};
change-theme
Change the current theme used by the application.
This command switches the application’s UI theme. The theme can be identified using either the theme id or name.
applicationproperty("current-theme") returns the currently active theme (for example { id: "blue", name: "Glacier" }).
applicationproperty("theme-list") returns the list of available themes.
If you want to prevent users from switching themes, consider disabling the theme switcher: settings.theme-switcher.
Parameters
- id: Text [optional/required] — The ID of the theme to activate. If not set,
namemust be provided. - name: Text [optional/required] — The name of the theme to activate. Can be used instead of the ID.
Example
return {
command: "change-theme",
id: "blue" // Use applicationproperty("theme-list") to get available theme IDs.
// name: "Glacier"
};
changetool
Change the current tool in the application.
Some tools require the application to be in a valid state before execution. For example, finishing a “New feature” drawing before switching tools.
Parameters
- tool: Text [required] — The tool to switch to. Valid values include:
new,select,environments,show-snapping-settings,reshape,reshapeline,networkreshape,associate,paste,paste-add,delete,pan,merge,change-offset-bevel,change-offset-round,change-offset-miter,change-offset-left,change-offset-right,lockstencilaspect-on,lockstencilaspect-off,finish-drawing,cancel-drawing,switch-follow-drawing-mode,switch-freehand-drawing-mode, etc.
Example
return {
command: "changetool",
tool: "select"
};
clear-scheduled-activity
Remove a previously scheduled activity from the application.
Parameters
- handle: Text [required] — The unique handle name of the scheduled activity to remove.
Example
return {
command: "clear-scheduled-activity",
handle: "uniquehandlename"
};
clear-selection
Clear all currently selected features in the application.
Example
return {
command: "clear-selection"
};
clear-undoredo
Clear the application’s undo and redo history.
Example
return {
command: "clear-undoredo"
};
closepanels
Close all open panels in the application interface.
Example
return {
command: "closepanels"
};
close-webpage
Closes an open URL that was launched from the application.
Example
return {
command: "close-webpage"
};
set-dimension-measures
Change the current measurement mode used for dimensions in the application.
Use applicationproperty("app-state").dimensionMeasures to get the current dimension measurement settings.
Parameters
- visible: Boolean [required] — Flag indicating whether dimension measurements should be visible in the application (
trueorfalse).
Example
return {
command: "set-dimension-measures",
visible: true
};
disable-capability
Disables a capability in the user interface.
Parameters
- capabilities: Array [required] — List of capability IDs to disable. Examples include:
command.new,command.save,command.choosefeature,command.reshape,command.delete,command.reshapeline,command.select,command.selectmode-select,command.selectmode-unselect,command.selectmode-lasso-select,command.selectmode-unselect,command.add,command.subtract,command.split,command.merge,command.unprotect,command.protect,command.effects,command.undo,command.redo,command.copy,command.paste,command.paste-with-attributes,command.associate,command.associate-contains,command.associate-containedby,command.associate-connect,command.associate-attach,panel.basemaps,panel.plans,panel.levels,panel.effects,panel.protect,panel.stencils,panel.find,panel.connectivity,panel.layers,panel.selection,panel.attributes,panel.actions,panel.messages,panel.dfeedback,map.dpad,footer.measure,footer.snapping,footer.snapping-control,footer.dpad-toggle,footer.selection,footer.linearfeature-line-length,footer.linearfeature-start,footer.linearfeature-end,footer.linearfeature-route,footer.stencil-rotate,footer.stencil-aspect,footer.stencil-size,footer.feature-line-length,footer.feature-segment-length,footer.feature-angle,footer.feature-offset,settings.theme-switcher,footer.location,footer.scale,draw.curves,draw.freehand,draw.follow,draw.coordinates,draw.flood,settings.dimensions-showmeasures, or a custom panel likepanel.[PANELNAME].
Example
return {
command: "disable-capability",
capabilities: ["command.pan"]
};
set-dpad
Change the d-pad state in the application.
See applicationproperty("app-state").dpad for the current value.
Parameters
- visible: Boolean [required] — Flag indicating whether the d-pad should be visible (
trueorfalse).
Example
return {
command: "set-dpad",
visible: true
};
set-layer-editscale
Set the editing scale for a specific layer in the application.
Parameters
- layer: Text [required] — The title of the layer for which the editing scale is being set.
- minscale: Number [required] — The minimum scale (most zoomed out) at which the layer is editable (e.g., 1000 for 1:1000).
- maxscale: Number [required] — The maximum scale (most zoomed in) at which the layer is editable. Use 0 for no restriction.
Example
return {
command: "set-layer-editscale",
layer: "<Layer Title>",
// The minimum scale (most zoomed out) at which the layer is editable.
minscale: 1000, // 1:1000
// The maximum scale (most zoomed in) at which the layer is editable.
// NOTE: 0 means that there is no restriction.
maxscale: 0 // not restricted to max scale.
};
enable-capability
Enables a capability in the user interface.
Parameters
- capabilities: Array [required] — List of capability IDs to enable. Examples include:
command.new,command.save,command.choosefeature,command.reshape,command.delete,command.reshapeline,command.select,command.selectmode-select,command.selectmode-unselect,command.selectmode-lasso-select,command.selectmode-unselect,command.add,command.subtract,command.split,command.merge,command.unprotect,command.protect,command.effects,command.undo,command.redo,command.copy,command.paste,command.paste-with-attributes,command.associate,command.associate-contains,command.associate-containedby,command.associate-connect,command.associate-attach,panel.basemaps,panel.plans,panel.levels,panel.effects,panel.protect,panel.stencils,panel.find,panel.connectivity,panel.layers,panel.selection,panel.attributes,panel.actions,panel.messages,panel.dfeedback,map.dpad,footer.measure,footer.snapping,footer.snapping-control,footer.dpad-toggle,footer.selection,footer.linearfeature-line-length,footer.linearfeature-start,footer.linearfeature-end,footer.linearfeature-route,footer.stencil-rotate,footer.stencil-aspect,footer.stencil-size,footer.feature-line-length,footer.feature-segment-length,footer.feature-angle,footer.feature-offset,settings.theme-switcher,footer.location,footer.scale,draw.curves,draw.freehand,draw.follow,draw.coordinates,draw.flood,settings.dimensions-showmeasures, or a custom panel likepanel.[PANELNAME].
Example
return {
command: "enable-capability",
capabilities: ["command.pan"]
};
set-layer-filter
Apply a filter to a specific layer in the map.
Parameters
- layer: Text [required] — The title of the layer to apply the filter to.
- filter: Text [required] — The filter expression to apply, e.g.,
FIELDNAME='ABCD'.
Example
return {
command: "set-layer-filter",
layer: "<Layer Title>",
filter: "FIELDNAME='ABCD'"
};
flash
Flash a specific location on the map.
Parameters
- geometry: Geometry [required] — The point, line, or polygon geometry to flash.
Example
return {
command: "flash",
// Example for a point
geometry: Point({ x: 1000, y: 1000, spatialReference: { wkid: 102100 } })
// Example for a polyline
//geometry: Polyline({
// paths: [
// [
// [x1, y1],
// [x2, y2],
// [x3, y3]
// ]
// ],
// spatialReference: { wkid: 102100 }
};
location-autopan
Auto-pan the map to keep the current GPS location in view.
Parameters
- autopan: Boolean [required] — Flag to auto-pan the map (
trueorfalse).
Example
return {
command: "location-autopan",
autopan: true
};
location-display
Show or hide the current GPS location as a point on the map.
Parameters
- show: Boolean [required] — Flag to display the current GPS location (
trueorfalse).
Example
return {
command: "location-display",
show: true
};
location-accuracydisplay
Show or hide the GPS accuracy as text on the map.
Parameters
- show: Boolean [required] — Flag to display the GPS accuracy on the map (
trueorfalse).
Example
return {
command: "location-accuracydisplay",
show: true
};
location-coordinatesdisplay
Show or hide the GPS coordinates as text on the map.
Parameters
- show: Boolean [required] — Flag to display the GPS coordinates on the map (
trueorfalse).
Example
return {
command: "location-coordinatesdisplay",
show: true
};
location-capture-mode
Set how GPS points are captured on the map.
Parameters
- mode: Text [required] — Capture mode for GPS points. Options include
"standard"or"averaging". - averagingpointcount: Number [required] — Number of points to average when
modeis set to"averaging". Required if using"averaging".
Example
return {
command: "location-capture-mode",
mode: "averaging",
averagingpointcount: 10
};
location-capture-accuracy
Specify the required accuracy for GPS location capture.
Parameters
- accuracy: Number [required] — Required accuracy in meters for GPS location capture.
Example
return {
command: "location-capture-accuracy",
accuracy: 5
};
imagery-layer-settings
Change settings for an imagery layer.
Parameters
- layer: Text [required] — Title of the layer to modify.
- layerid: Text [optional] — ID of the layer (alternative to layer title).
- layername: Text [optional] — Name of the layer (can be same as title).
- filter: Text [optional] — Filter expression to apply to the layer.
- renderingRule: Object [optional] — Raster function to apply. Use REST JSON; pay attention to property casing, or provide as a string.
Example
return {
command: "imagery-layer-settings",
layer: "<Layer Title>"
// layerid: "" // optional
// layername: "" // optional
// filter: "" // optional
// renderingRule: {} // optional
};
set-layer-geometry-display-filter
Set a layer to have a geometry display filter. Filtered geometries will not be selectable or used elsewhere in the application.
Parameters
- layer: Text [required] — Title of the layer to apply the filter. Can also use
layerid. - layerid: Text [optional] — ID of the layer (alternative to layer title).
- geometry: Geometry [required] — The geometry to use as the filter (e.g.,
$currentMapExtent). - spatialRelationship: Text [optional] — Spatial relationship to apply (for example,
"intersects").
Example
return {
command: "set-layer-geometry-display-filter",
layer: "<Layer Title>", // optional: layerid instead
geometry: $currentMapExtent,
spatialRelationship: "intersects"
};
set-layer-opacity
Set a layer’s opacity.
Parameters
- layer: Text [required] — The title of the layer whose opacity you want to set.
- opacity: Number [required] — The opacity value for the layer, between 0 (fully transparent) and 1 (fully opaque).
Example
return {
command: "set-layer-opacity",
layer: "<Layer Title>",
opacity: 0.75
};
set-layer-visibility
Set a layer’s visibility.
Parameters
- layer: Text [required] — The title of the layer whose visibility you want to set.
- visible: Boolean [required] — Flag indicating whether the layer should be visible (
trueorfalse).
Example
return {
command: "set-layer-visibility",
layer: "<Layer Title>",
visible: true
};
set-legend-layer-visibility
Set a layer’s visibility in the legend.
Parameters
- layer: Text [required] — The title of the layer whose legend visibility you want to set.
- listmode: Text [optional] — The legend display mode. Possible values:
show,hide,hide-children.
Example
return {
command: "set-legend-layer-visibility",
layer: "<Layer Title>",
listmode: "hide" // could be 'show' | 'hide-children'
};
select
Select features in a layer using a spatial or graphic filter.
Parameters
- method: Text [required] — Selection method. Use
newto make a new selection,addto append to current selection,removeto remove from current selection. - layers: Array [required] — List of layers to select features from. Each object can include:
- layername or layerid: Text [required] — The layer title/id.
- graphics: FeatureSet [required] — The set of features to select, e.g., using
intersects(FeatureSetByName($map, "<Layer Title>"), ext)or if using layeridintersects(FeatureSetById($map, "<Layerid>"), ext). Required if sql not set. - sql: Text [required] — The SQL query to filter by. Required if graphics not set.
Example
var ext = Extent({ xmin: 1000, ymin: 1000, xmax: 1000, ymax: 1000, spatialReference: { wkid: 102100 } });
return {
command: "select",
method: "new",
layers: [
{
layername: "<Layer Title>", //Could be layerid = "<LayerId>"
graphics: intersects(FeatureSetByName($map, "<Layer Title>"), ext) //Could be FeatureSetById
//sql: "OBJECTID=12" //Alternative to graphics
}
]
};
set-measurements
Change the measurements display state.
See applicationproperty("app-state").measure for the current value.
Parameters
- visible: Boolean [required] — Flag indicating whether measurements should be visible (
trueorfalse).
Example
return {
command: "set-measurements",
visible: true
};
panto
Pan to a location.
Parameters
- geometry: Geometry [required] — The geometry location to pan the map to.
- flash: Boolean [optional] — Flag indicating whether the location should flash on the map (
trueorfalse).
Example
return {
command: "panto",
// For a point
geometry: Point({ x: 1000, y: 1000, spatialReference: { wkid: 102100 } }),
flash: true
// For an extent
//geometry: Extent({
// xmin: 1000,
// ymin: 1000,
// xmax: 1000,
// ymax: 1000,
// spatialReference: { wkid: 102100 }
// })
};
openpanel
Open a panel in the application.
Parameters
- panel: Text [required] — The panel ID to open. For standard panels, the following options are available:
panel.basemaps,panel.plans,panel.levels,panel.effects,panel.protect,panel.stencils,panel.find,panel.connectivity,panel.layers,panel.selection,panel.attributes,panel.actions,panel.messages,panel.dfeedback.
If you want to open a custom panel, you can usepanel.[PANELNAME].
Example
return {
command: "openpanel",
panel: "panel.find" // For a custom panel use "panel.[<panel name>]"
};
set-panel-width
Set the width of a panel.
Parameters
- panel: Text [required] — The panel to adjust. Options include:
leftorright. - width: Number [required] — The width of the panel in pixels. Must be greater than 0.
Example
return {
command: "set-panel-width",
panel: "left", // Could be "right"
width: 100 // Width is in pixels. Must be greater than 0.
};
refresh-layer
Refresh a layer on the map.
Parameters
- layer: Text [required] — The layer to refresh. Can be specified by layer name.
Example
return {
command: "refresh-layer",
layer: "<Layer Title>"
};
remove-reference-layer
Remove a reference layer from the map.
Parameters
- layerid: Text [required] — The ID of the reference layer to remove.
Example
return {
command: "remove-reference-layer",
layerid: "<theid>"
};
reset-action
Resets the form parameters of an action.
Parameters
- name: Text [required] — The name of the action to reset.
- params: Dictionary [optional] — Optional dictionary of parameter values to reset the action with. Use
nullto reset all parameters.
Example
return {
command: "reset-action",
name: "<Command name>",
params: null
};
reset-layers
Refresh a layer and remove all temporary data. This command is recommended to be used with applications using command saving.
Parameters
- layers: Array [required] — List of layer names to reset.
Example
return {
command: "reset-layers",
layers: ["<Layer Title>"]
};
set-maprotation
Change the map rotation.
See applicationproperty("app-state").rotation for the current value.
Parameters
- rotation: Number [required] — The rotation angle of the map in degrees.
Example
return {
command: "set-maprotation",
rotation: 50
};
run-action
Run an action.
Parameters
- name: Text [required] — The name of the action to run.
- params: Dictionary [optional] — Parameter values for the action, or
nullif none.
Example
return {
command: "run-action",
name: "<Command name>",
params: null // Can be the parameters
};
schedule-activity
Schedule an activity to occur when the database is updated.
Parameters
- handle: Text [required] — Unique name used to identify and remove the scheduled activity.
- event: Text [optional] — Event to listen for (e.g.,
"data-written"). - filter: Array [optional] — Layers to monitor, e.g.,
["."] - interval: Number [optional] — Milliseconds between scheduled runs. Event must be removed if using this.
- commands: Array [required] — List of commands to execute when triggered.
Example
return {
command: "schedule-activity",
// Used to remove a scheduled activity. Name is unique.
handle: "uniquehandlename",
// Listen for data write events. Other values are same as listeners.
event: "data-written",
// filter: ["<LAYER INTEREST>"], // Optional
// Can do schedule instead of event.
// interval: 10000, // This is milliseconds. Event tag must be removed.
commands: [
{
command: "show-message",
message: "Data Written",
style: "BubbleInfo"
}
]
};
schedule-save-after-operation
Cause a save after the action has run.
Example
return {
command: "schedule-save-after-operation"
};
set-clipboard
Command to set clipboard data in the application.
Parameters
- textvalue: Text [optional] — Copies a text value to be pasted into forms or similar.
- geometry: Geometry [optional] — Copy any geometry to the clipboard.
- layers: Array [required] — List of layer dictionaries defining which graphics to copy. Each object can include:
- layername or layerid [required]: Text — The layer title/id.
- graphics: FeatureSet [required/optional] — The set of graphics, e.g., using
intersects(FeatureSetByName($selection,"or if using layerid"),$currentMapExtent) intersects(FeatureSetById($selection,"."),$currentMapExtent) - sql: Text [required/optional] — The SQL query to filter by. Alternative to graphics.
Example
return { command: "set-clipboard", // Use one of the following examples: "textvalue": "Hello World" // Copies a text value to be pasted into forms or similar. // The examples below will copy the geometries / graphics to the clipboard for use in operations. // OR //"geometry": union(FeatureSetByName($selection,"<LAYER NAME>")) // Any geometry can be added here // OR /* layers: [ { layername: "<LAYER NAME>", // layerid: "<LAYERID"> // Alternative to using layername graphics: intersects(FeatureSetByName($selection,"<LAYER NAME>"),$currentMapExtent) // a set of graphics, could be FeatureSetById //sql: "OBJECTID=11" //Alternative to graphics } ] };set-active-feature-template
Change active new feature type.
Parameters
- layer: Text [required] — The layer containing the feature template.
- template: Text [required] — The feature template to set as active.
Example
return { command: "set-active-feature-template", layer: "Trees", template: "Oak" };set-active-selection-layers
Change which layers are being used for selections.
Parameters
- layerids: Array [required] — List of layer IDs to use for selections. One of
layeridsorlayernamesis required. - layernames: Array [required] — List of layer names to use for selections. One of
layeridsorlayernamesis required.
Example
return { command: "set-active-selection-layers", // Either provide a list of "layerids" or // a list of layer names. // layerids: ["<LAYERID", "LAYERID"], layernames: ["<LAYERNAME>", "<LAYERNAME>"] };set-cogo
Set the COGO footer values.
Note the COGO footer values will be recalculated if the app is set to a different unit length to metres.
Parameters
- length: Number [optional] — Fixed segment length in meters. Use
nullto unset. - angle: Number [optional] — Fixed angle (0–360). Use
nullto unset. - offset: Number [optional] — Fixed offset in meters. Use
nullto unset.
Example
return { command: "set-cogo", // The following values are all optional "length": 100, // Fixed segment length (in meters). Use null to unset. "angle": 50, // Fixed angle (0-360). Use null to unset. "offset": 100 // Fixed offset (in meters). Use null to unset. };set-drawmode
Sets the draw mode.
Parameters
- mode: Text [required] — The drawing mode to set. Options include
"standard","curves","follow","stencil","freehand".
Example
return { command: "set-drawmode", mode: "standard" // Could be "curves", "follow", "stencil", "freehand". };set-gdbversion
Set the geodatabase version for the application.
Note: This will reset everything. It clears undo/redo and the commit stack. Switching version cannot keep these artifacts valid. It changes all layers and tables in the same service as the primary geodatabase version layer (configured in the builder).
Parameters
- silent: Boolean [required] — If
false, will not show warning messages before switching. - version: Text [required] — The SDE version to switch to.
Example
return { command: "set-gdbversion", silent: false, // Will not show warning messages before switching. version: "<SDE VERSION>" };set-level
Set the active facility and level.
Note: If a facility or level cannot be found, the facility and level will be cleared.
Parameters
- silent: Boolean [required] — If
false, warning messages before switching will not be shown. - facility: Text [optional] — The facility ID to set. If set to
"", the current facility will be unset. - level: Text [optional] — The level ID in the facility. If set to
"", the current level will be cleared. - reload: Boolean [optional] — Set to
trueto force the facility and level data to be reloaded.
Example
return { command: "set-level", silent: false, // Will not show warning messages before switching facility: "{1234-1234-1234-1234}", // Facility ID to set. "" unsets the current facility level: "{1234-1234-1234-1234}", // Level ID in the facility. "" clears the current level reload: false // Optional. Set to true to force reload of facility and level data };set-sessionvariable
Set a session variable.
Parameters
- variable: Text [required] — The name of the session variable to set.
- value: Any [required] — The value to assign to the session variable.
Example
return { command: "set-sessionvariable", variable: "<VariableName>", value: "<ANY VALUE>" };set-snapping
Sets the snapping state.
Parameters
- state: Boolean [required] — Enable or disable snapping (
trueorfalse). - drawhinting: Boolean [optional] — Enable or disable draw hinting (
trueorfalse). - hinting: Boolean [optional] — Enable or disable snapping hinting (
trueorfalse). - edgesnapping: Boolean [optional] — Enable or disable edge snapping (
trueorfalse). - vertexsnapping: Boolean [optional] — Enable or disable vertex snapping (
trueorfalse). - connectivitysnapping: Boolean [optional] — Enable or disable connectivity snapping (
trueorfalse). - snappinglayers: Array [optional] — List of layer IDs to apply snapping to.
Example
return { command: "set-snapping", state: true, drawhinting: false, hinting: false, edgesnapping: false, vertexsnapping: false, connectivitysnapping: true, snappinglayers: ["<layerId>", "<layerId>"] };show-environments-dialog
Show environments dialog.
Example
return { command: "show-environments-dialog" };show-message
Show a message.
Parameters
- message: Text [required] — The message to display.
- html: Boolean [optional] — If
true, the message is shown as HTML in bubble messages. - duration: Text [optional] — Duration of the bubble message. Could be
"medium","slow","fast", or number of milliseconds. - style: Text [required] — Style of the message. Options:
"InfoMessage","WarnMessage","BubbleInfo","BubbleWarn","BubbleError".
Example
return { command: "show-message", message: "<b>Hello World!</b><br><span style='color: #0078D4;'>This is some HTML content.</span>", html: true, // If set to true, will show as HTML in bubble messages. // "duration": "medium", // Could be "medium" | "slow" | "fast" | milliseconds style: "BubbleInfo" // Could be "InfoMessage", "WarnMessage", "BubbleInfo", "BubbleWarn", "BubbleError". };set-expand-state
Find the state of the application and toggle the expanded state of UI elements.
Parameters
- element: Text [required] — The element to change the expanded state for, e.g.,
"main-aside"or"drawing-menu". - expanded: Boolean [required] — Set to
trueto expand orfalseto collapse. Can use!applicationState[element].expandedto toggle.
Example
var applicationState = applicationProperty("app-state"); return [ { command: "set-expand-state", element: "main-aside", expanded: !applicationState.mainAside.expanded }, { command: "set-expand-state", element: "drawing-menu", expanded: !applicationState.drawingMenu.expanded } ];zoomto
Zoom to a location.
Parameters
- geometry: Geometry [required] — The geometry (point, extent, polygon, etc.) to zoom to.
Example
return { command: "zoomto", // For an extent geometry: Extent({ xmin: 1000, ymin: 1000, xmax: 1000, ymax: 1000, spatialReference: { wkid: 102100 } }) };