Commands and Operations
Commands and operations are runnable, independent units of work within Geocortex Web. Commands and operations act as global functions which can be executed from any component or service.
Commands and operations have one key difference. Commands execute behavior that can have effects on the application, while operations produce outputs which can be passed to commands. Commands and operations can be run sequentially in what's called a "command chain" to enable complex behavior.
Commands and Operations are grouped by namespace, for example:
auth.sign-in
auth.sign-out
edit.add-feature
edit.delete-features
tip
The full list of existing commands and operations available in Geocortex Web can be found in the API documentation.
Commands and operations are used to power much of Geocortex Web's built in behavior and interactions. They can be run through configuration, or through custom services or components.
One thing that makes commands and operations so powerful is that built in components have properties in the app config which take them as values. They power everything from basic components like the IWTM, to advanced functionality like the results list. This allows built-in component's internal behavior to be configured with different commands and operations.
Workflow Command
Geocortex Workflow can allow for the creation of completely customized behavior without writing custom code. Geocortex Web has a special command, workflow.run
, which allows you to run workflows anywhere you would run a command or operation. Using workflow, you can take custom behavior in Geocortex Web further without having to write custom code.
Check out this example of running a workflow from app config.
Configuring Commands and Operations
Commands and operations can be used through the app config to customize built in components.
App config properties like action
can accept a singular command/operation or a command chain .
note
Command chains are arrays of commands and operations which are executed sequentially. The output of previous operations is passed along the chain to future operations and commands, allowing for complex input dependent behavior.
Passing Explicit Arguments
Commands and operations can be configured with an arguments
property that passes values to the function at execution time.
tip
You can find out what arguments a command or operation takes in the commands and operations API reference.
Passing Implicit Arguments
If you do not pass explicit arguments, then implicit arguments will be passed to the command or operation. Implicit arguments come from the context that a command or operation is running in, or from a previous operation in the command chain
For example, let's look at the configuration for the onFeatureClick
property of a <results-list>
component model.
In this example, the context is an item in the results list, so results.display-details
will receive an argument with a Features
property, which is the shape of argument it needs.
Arguments are also passed implicitly if you create a command chain, which runs operations one after the other.
Command Chains
App config properties that accept a command or operation can take a single operation or they can take a command chain. Command chains are arrays of commands and operations which are executed sequentially. The output of previous operations is passed along the chain to future operations, allowing for complex chains of behavior.
For example, here's configuration for the various behaviors of a <results-list>
component.
Since these commands and operations are running from the context of a <results-list>
component, the first command or operation will receive the relevant feature as its input. If the property is a command chain, the next step in line will receive one of two possible inputs.
- If the previous step was a command (which doesn't produce output), then the original input is passed on to the next step.
- If the previous step was an operation (which produces an output), then the output of that operation is passed onto the next step.
In this way, you can run multiple commands in a row that receive a feature as input, as seen in the action
command chain of zoom-to-features
in the example.
The action
command chain of save-features-to-csv
demonstrates how an operation can pass its output to the next command or operation in the list. In this case, it's passing the CSV content to system.download-file
.
Example: Configured Map and I Want to Menu
This example demonstrates two different types of argument passing behavior.
- App Config
- Layout
Let's first look at the command chain defined on the onClick
property of a map. This chain consists of three operations and commands:
task.identify
,highlights.add-focus
results.display
tasks.identify
does not have any named arguments defined, so it will take arguments passed into it from its current context. Since this chain is run on a map click, the context argument passed in has the shape:
tasks.identify
receives this argument, and since it is an operation, produces an output. Looking at the Commands and Operations Documentation, tasks.identify
has output of type Features
.
highlights.add-focus
and results.display
both take a Features
type input, so the output of tasks.identify
will work nicely. highlights.add-focus
is immediately after tasks.identify
, so it receives the output of identify. Since highlights.add-focus
is a command, it does not produce any output. Therefore, results.display
will receive the output of the last operation, tasks.identify
. In this way, you can pass the output of an operation to multiple commands.
The second behavior in this application is a map.zoom-to-initial-viewpoint
command on the I Want To Menu. This command takes Maps
type argument. The argument
property in the app config supplies an array of maps by referencing the default
map with an Item URI. Item URIs are a way of referencing other items within the app config.
Next Steps
Geocortex Web has a large array of built-in command and operations that you can chain to power custom behavior. Custom commands and operations can also be implemented with the SDK.
Commands, Operations, and Events API
Check out the available commands and operations
Run a Command or Operation with a Button
Learn how to configure a button to run a command or operation
Build your own Commands and Operations
Use the SDK to implement custom commands and operations
Learn about Events built into Geocortex Web
Learn about the global event infrastructure in Geocortex Web