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 Geocortex 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 Geocortex 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.

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 a 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 Geocortex Workflow Designer and create and save a new workflow.
tip

Optionally, you can download this example workflow that displays an alert and then import it into the Geocortex Workflow Designer.

  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 Geocortex Workflow

Implement a Custom Activity

Learn how to implement a custom activity with the Geocortex Workflow SDK

Implement a Custom Form Element

Learn how to implement a custom form element with the Geocortex Workflow SDK

Change Geocortex Web's Default Map Click Behavior

Learn how to Geocortex Workflow to override Geocortex Web's default map click behavior