Run a Workflow from App Config

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 Mobile 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 Mobile SDK and editing the minimal layout and app config provided.

tip

If you just need to make a small change to the layout and app config of an existing application, you can download the config and layout files for the application, tweak them, and then re-upload them.

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

app/layout-large.xml
<?xml version="1.0" encoding="utf-8" ?>
<layout
xmlns="https://geocortex.com/layout/v1"
xmlns:gxm="https://geocortex.com/layout/mobile/v1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://geocortex.com/layout/v1 ../../ViewerSpec/layout/layout-mobile.xsd">
<gxm:taskbar id="taskbar" orientation="vertical">
<map/>
</gxm:taskbar>
</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
{
"$schema": "..\\..\\ViewerFramework\\app-config\\mobile\\mobile-app-config.schema.json",
"schemaVersion": "1.0",
"items": [
{
"$type": "layout",
"id": "desktop-layout",
"url": "resource://layout-large.xml",
"tags": ["mobile", "large"]
},
{
"id": "map-config",
"$type": "map-extension",
"webMap": "0ba877a4185448cb832af9a661031e31",
"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.
tip

The target property of the workflow app item determines the container in which the workflow UI, such as a form, will be displayed.

app/app.json
{
"$schema": "..\\..\\ViewerFramework\\app-config\\mobile\\mobile-app-config.schema.json",
"schemaVersion": "1.0",
"items": [
{
"$type": "layout",
"id": "desktop-layout",
"url": "resource://layout-large.xml",
"tags": ["mobile", "large"]
},
{
"id": "map-config",
"$type": "map-extension",
"webMap": "0ba877a4185448cb832af9a661031e31",
"onInitialized": [
{
"name": "ui.display-notification",
"arguments": {
"message": "Map initialized"
}
}
]
},
{
"$type": "workflow",
"id": "map-initialized-workflow",
"title": "Map Initialized Workflow",
"target": "#taskbar",
"commandArgumentInput": "context",
"portalItem": "<your-workflow-id-here>"
}
]
}

Finally, you can configure the map to run this workflow on initialization.

app/app.json
{
"$schema": "..\\..\\ViewerFramework\\app-config\\mobile\\mobile-app-config.schema.json",
"schemaVersion": "1.0",
"items": [
{
"$type": "layout",
"id": "desktop-layout",
"url": "resource://layout-large.xml",
"tags": ["mobile", "large"]
},
{
"id": "map-config",
"$type": "map-extension",
"webMap": "0ba877a4185448cb832af9a661031e31",
"onInitialized": [
{
"name": "workflow.run",
"arguments": {
"id": "map-initialized-workflow"
}
}
]
},
{
"$type": "workflow",
"id": "map-initialized-workflow",
"title": "Map Initialized Workflow",
"target": "#taskbar",
"commandArgumentInput": "context",
"portalItem": "cd6bd434f3a44b479e06446318269e71"
}
]
}

Relevant SDK Samples

The Geocortex Mobile SDK Samples project has a variety of workflow samples:

Next Steps

Geocortex Workflow

Learn more about Geocortex Workflow

Change the Default Map Click Behavior with a Workflow

Learn more about overriding default behaviors