A viewer command is an instruction to the viewer to perform a particular action. For example, the ShowLayerList
command tells the viewer to display the layer list.
The HTML5 viewer uses the commands in its repertory to implement the features and functions it offers. In addition, you can use viewer commands in hyperlinks and workflows, as described below.
Because commands typically perform a very simple action, the HTML5 viewer sometimes runs several commands one after the other to perform more complex actions.
Some commands need objects or values to work with when performing their action—these objects and values are the command's parameters. The definition of a command specifies how many parameters the command has, the type of each parameter, and whether the parameter is required or optional. For example, the Alert
command has two required parameters—the alert's title and message, both strings—and one optional parameter—a function that indicates how the user responded to the alert.
Viewer commands can be embedded in HTML anchor elements. When the user clicks the hyperlink, the command executes. For example, an anchor element with a call to the ZoomToInitialExtent
command in it returns the map to its initial extent when the user clicks the hyperlink.
Viewer commands can be used in the Feature Description and Feature Long Description boxes on a layer's Details tab in Manager—these two boxes can have HTML markup entered in them. To open a layer's Details tab, edit the layer.
You can use any viewer command in feature descriptions and feature long descriptions. For a complete list of available commands, refer to Viewer Commands and Events.
To configure a viewer command in an HTML anchor element, you put command:CommandName
in the href
attribute, where CommandName
is the name of the viewer command. In its simplest form, an anchor element containing a viewer command looks like this:
<a href="command:CommandName">Hyperlink Text</a>
In this case, the viewer command does not have any parameters.
For a command that takes parameters, the command name is followed by a question mark and a query string that specifies the parameters:
<a href="command:CommandName?QueryString">Hyperlink Text</a>
Query strings:
must be HTML encoded and URL encoded
can contain
can use HTTP query string syntax or JSON encoding
You cannot use Manager's built-in Rich Text Editor to enter viewer commands—you must type them in.
Hyperlinked viewer command in Manager (top) and in the viewer
Examples
Command with No Parameters:
<a href="command:OpenOverviewMap">Open Overview Map</a>
Command with a String Parameter:
<a href="command:RunWorkflowById?Basic_Workflow">Basic Workflow</a>
Command with an Object Token as the Parameter:
<a href="command:ShowFeatureDetails?{$Feature}">Show Details</a>
RunWorkflowWithArguments Command:
The RunWorkflowWithArguments
command is used to run workflows that take one or more arguments. In this case, the command parameters are key-value pairs, where the key is the argument's name that you defined in Workflow Designer.
In the following example, the workflow takes two arguments: parcelId
and geometry
. {PID}
is a field token that represents the parcel ID of the currently selected parcel. {$Geometry}
is an object token that represents the geometry of the currently selected feature. In this context the feature is a parcel.
<a href="command:RunWorkflowWithArguments?workflowId=Workflow1&parcelId={PID}&geometry={$Geometry}">Run Workflow</a>
To run a workflow, you must specify the workflow ID in addition to the workflow arguments.
You can use the {$Graphic} and {$Geometry} object tokens with the RunWorkflowWithArguments
command. You cannot use the {$Feature} object token with the RunWorkflowWithArguments
command.
JSON-Encoded Parameters:
In the HTML5 viewers, you can use JSON encoding for any command.
<a href="command:ZoomToExtent?{"xmin" : 1384615, "ymin" : 460976, "xmax" : 1536998, "ymax" : 646328 }">Zoom to Extent</a>
To determine if a particular command can be used in hyperlinks, find the command in Viewer Commands and Events.
Commands that cannot be used in hyperlinks include a note indicating the limitation in the description area of the command. If there is no such note, then you can safely use the command in hyperlinks.
The Run External Command workflow activity runs the specified viewer command. This means you can create workflows that use many of the same commands that the viewer itself uses.
For information on the Run External Command activity, refer to the "Activity Library" | "Common Viewer Activities" | "Run External Command" section of the Workflow Designer help system (run Workflow Designer from the Start menu, and then click the help icon in the toolbar).
To determine if a particular command can be used in workflows, find the command in Viewer Commands and Events.
Commands that cannot be used in workflows include a note indicating the limitation in the description area of the command. If there is no such note, then you can safely use the command in workflows. Some commands have restrictions on how they are used—these restrictions are also described.