Skip to main content

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.

Important

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

First, let's create a basic map using the layout and app config.

app/layout.xml
<?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/app.json
{
"schemaVersion": "1.0",
"items": [
{
"id": "map-config",
"$type": "map-extension",
"onInitialized": [
{
"name": "ui.display-notification",
"arguments": {
"message": "Map initialized"
}
}
]
}
]
}

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.

  1. Open up VertiGIS Studio Workflow Designer and create and save a new workflow.
tip
  1. Add an "Alert" activity as a test.
  2. Copy the ID of the the workflow from the URL

  1. Add the workflow as an app item to your app config.
app/app.json
{
"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/app.json
{
"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>"
}
]
}

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.

tip

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