Run a Workflow from App Config
Many components have default behaviors which can be configured through the app config JSON. Any configurable property which takes a command or operation as its value can also be configured with a special command, workflow.run
. By using the workflow.run
command, you can even execute a workflow with completely configurable behavior.
In this article, we can configure a workflow to run when the map is initialized.
Configuring a workflow to run when the map is initialized can be done through VertiGIS Studio Web Designer and this is the preferred method of configurable if Designer can be used. The goal of this article is to demonstrate the pattern of overriding behaviors with workflows.
Prerequisites
- Follow along by setting up the VertiGIS Studio Web SDK and editing the minimal layout and app config provided.
- Check out the deployment instructions to learn about how to deploy layout and app config to an application.
First, let's create a basic map using the layout and app config.
- Layout
- App Config
{
"schemaVersion": "1.0",
"items": []
}
<?xml version="1.0" encoding="UTF-8"?>
<layout xmlns="https://geocortex.com/layout/v1" xmlns:custom="your.custom.namespace">
<map/>
</layout>
Next, add an app item to the configuration for the map component, and configure the map to run ui.display-notification
on initialization as a test.
- App Config
- Layout
{
"schemaVersion": "1.0",
"items": [
{
"id": "map-config",
"$type": "map-extension",
"onInitialized": [
{
"name": "ui.display-notification",
"arguments": {
"message": "Map initialized"
}
}
]
}
]
}
<?xml version="1.0" encoding="UTF-8"?>
<layout xmlns="https://geocortex.com/layout/v1" xmlns:custom="your.custom.namespace">
<map config="map-config"/>
</layout>
The next step is going to be replacing the ui.display-notification
command with a workflow.run-*
command. First, we need to create a workflow to use for the command.
- Open up VertiGIS Studio Workflow Designer and create and save a new workflow.
Optionally, you can
download this example workflow
that displays an alert and then
import it into the VertiGIS Studio Workflow Designer.
- Add an "Alert" activity as a test.
- Copy the ID of the the workflow from the URL
https://apps.vertigisstudio.com/workflow/designer/#workflow= 44010fc421dd4659b74fb921e09ba594
- Add the workflow as an app item to your app config.
{
"schemaVersion": "1.0",
"items": [
{
"id": "map-config",
"$type": "map-extension",
"onInitialized": [
{
"name": "ui.display-notification",
"arguments": {
"message": "Map initialized"
}
}
]
},
{
"$type": "workflow",
"id": "map-initialized-workflow",
"title": "Map Initialized Workflow",
"commandArgumentInput": "context",
"portalItem": "<your-workflow-id-here>"
}
]
}
Finally, you can configure the map to run this workflow on initialization.
- App Config
- Layout
- UI
{
"schemaVersion": "1.0",
"items": [
{
"id": "map-config",
"$type": "map-extension",
"onInitialized": [
{
"name": "workflow.run",
"arguments": {
"id": "map-initialized-workflow"
}
}
]
},
{
"$type": "workflow",
"id": "map-initialized-workflow",
"title": "Map Initialized Workflow",
"commandArgumentInput": "context",
"portalItem": "<your-workflow-id-here>"
}
]
}
<?xml version="1.0" encoding="UTF-8"?>
<layout xmlns="https://geocortex.com/layout/v1" xmlns:custom="your.custom.namespace">
<map config="map-config"/>
</layout>
You've now successfully customized behavior through the app config with a workflow. From this point, you could develop the workflow further to solve your business case.
For a more in depth example, check out the tutorial on overriding default map click behavior with a workflow.
Next Steps
Build a Custom Form
Learn how to build a custom form with VertiGIS Studio Workflow
Implement a Custom Activity
Learn how to implement a custom activity with the VertiGIS Studio Workflow SDK
Implement a Custom Form Element
Learn how to implement a custom form element with the VertiGIS Studio Workflow SDK
Change VertiGIS Studio Web's Default Map Click Behavior
Learn how to use VertiGIS Studio Workflow to override VertiGIS Studio Web's default map click behavior