Server Workflows

Server workflows are workflows that run on the Workflow server, instead of on the client.

Server workflows run on the server only. For example, you cannot export a server workflow to JSON and run it from somewhere else.

Running workflows on the server allows you to do certain tasks that you cannot do on the client, like querying external databases, managing files on the server, and sending email.

Server workflows require on-premises Workflow. Cloud Workflow will not run server workflows.

Geocortex Workflow provides a number of activities that you can only use in server workflows, for example, Run SQL Query, Write File, Send Email, and Create Download. In addition, many activities can be used in both client workflows and server workflows.

Some server activities require preliminary setup. To use activities that run server-side SQL, first follow the steps in Database Connections for Server Workflows. To use the Send Email activity, configure the mail server's connection information.

To create a server workflow, select Server Workflow on the Info panel, and then build the workflow the same way you would build a client workflow—by dragging activities to the design surface, connecting them into a flowchart, and configuring their inputs. Selecting Server Workflow in the Info panel filters the Toolbox for activities that can be used in server workflows. This prevents you from using activities that Workflow Server does not support.

Server workflows are run by client workflows—end users cannot run server workflows directly. To run a server workflow, add a Run Workflow activity to a client workflow and configure the activity to run the server workflow. When the Run Workflow activity executes in the client workflow, the server workflow runs.

You can pass inputs from the client workflow to the server workflow by configuring the Run Workflow activity's Arguments input. The server workflow brings in the inputs using a Get Workflow Inputs activity. You can also pass an output back from the server workflow to the client workflow. To return an output, configure a Set Workflow Output activity in the server workflow. The client workflow accesses the output through the Run Workflow activity's result output.

To test a server workflow that you have authored, run it in the Sandbox just as you would a client workflow. In the Sandbox, you do not need to run a server workflow from a client workflow—you can run it directly. This makes it easier to test server workflows.

When you have created the client workflow that runs the server workflow, run the client workflow in the Sandbox. This not only tests the client workflow, it also tests the server workflow in the context of the client workflow. View the verbose log to see the inputs that are passed to the server workflow and the outputs that are returned.

The verbose log does not log server workflows. It only logs client workflows. If there is an error in a server workflow, the log will provide a link to an additional log to help you debug the server workflow.

Main Steps to Create and Run a Server Workflow

The main steps to create and run a server workflow are as follows:

  1. Create the server workflow.

  2. Configure a client workflow to run the server workflow.

  3. Run the client workflow.

Create and Run a Server Workflow

To create and run a server workflow:

This procedure assumes that you have already installed Geocortex Workflow on premises.

Step 1: Create a server workflow

  1. Sign in to Workflow Designer in your on-premises installation of Geocortex Workflow.

  2. Create a new workflow.

  3. Click Info in the sidebar to open the Info panel.

  4. Select Server Workflow as the Workflow Type.

    The server's URL shows on the Deployment panel.

  5. Build the workflow by adding, configuring, and connecting activities. If the workflow takes inputs from the client workflow, use a Get Workflow Inputs activity to get the inputs. If the workflow produces an output, use a Set Workflow Output activity to set the output.

  6. Test the workflow by running it in the Sandbox.

    You can run a server workflow directly in the Sandbox. You do not have to run it from a client workflow.

  7. Press Ctrl+S to save the workflow.

  8. Keep the server workflow open in Workflow Designer so you can access it in the next step.

Step 2: Configure a client workflow to run the server workflow

  1. Open or create a client workflow in your on-premises installation of Workflow Designer.

    Client workflows have Client Workflow selected on the Info panel. This filters the Toolbox for activities that can be used in client workflows. By default, workflows are client workflows.

  2. Run Workflow: At the point in the client workflow where you want to run the server workflow, add and connect a Run Workflow activity.

    Configure the activity:

    1. In the Url input, paste the URL of the server workflow.

      To get the server workflow's URL, click the tab for the server workflow in Workflow Designer, open the Info panel, and copy the workflow URL.

    2. If the server workflow takes one or more inputs, specify name/value pairs for the inputs in Arguments.

  3. If the server workflow produces an output, add activities to process the output.

    Access the output using an expression like =$runWorkflow1.result.Name, where Name is the name that you specified in the Set Workflow Output activity's Name input in the server workflow.

  4. Test the workflow by running it in the Sandbox.

    This tests the server workflow in the context of the client workflow.

  5. Press Ctrl+S to save the workflow.

Step 3: Run the client workflow

  1. Configure an application to host the client workflow. Run the client workflow from the host application.

    For instructions on configuring host applications, see Configure Host Applications.

Example - Use a Server Workflow to Query a Database

A common use for server workflows is to query a database. Typically, you will use the data table returned by the query in a form so the user can see and interact with the query results.

This example shows you how to query a database in a server workflow, return the data table to the client workflow, and use column values to populate a drop-down list. Instead of using a drop-down list, you could equally as well use an auto complete element or any other form element that has items.

The server workflow uses a Run SQL Query activity to query the database. The Run SQL Query activity returns a data table, which is a collection of objects with properties that represent columns. The server workflow uses a Set Workflow Output activity to return the data table as its output.

The client workflow runs the server workflow using a Run Workflow activity. To use the query results in a form, the client workflow has a Display Form activity with a Drop Down List form element. Because the data table is a collection, the client workflow uses a Get Form Element Items From Collection activity to convert a particular column of the data table to items that can be used to populate the drop-down list. The Set Form Element Items activity populates the drop-down list with the items.

To convert a data table to a feature set instead of form element items, use the Convert Data Table To Feature Set activity.

 

Workflow Logic

The workflows have the following activities, in the order shown:

To use a server workflow to query a database and return the query results to the client workflow:

Step 1: Create the server workflow

  1. In on-premises Workflow Designer, create a new workflow.

  2. On the Info panel, select Server Workflow as the Workflow Type.

  3. Add the following activities and connect them in the given order:

  4. Run SQL Query (sqlQuery1):

    1. Provider Name: Click in the Provider Name box to open a drop-down list of data providers and select the provider for the database you are going to query.

    2. Provide the database's connection information:

      • Connection Config Name: If you have configured the database's connection string in the databasesettings.json file, type the name from databasesettings.json in the Connection Config Name box.

      • Connection String: If you have not configured the database's connection string in the databasesettings.json file, type the database's connection string in the Connection String box. For information on storing connections strings, see Database Connections for Server Workflows.

    3. Command Text: Type the SQL statement that you want to use to query the database. For example:

      SELECT * FROM COMPANY.CUSTOMERS ORDER BY NAME

      For security reasons, you cannot use an expression to define the SQL statement.

    4. Parameters: If you need to inject values into the SQL statement, specify them as name/value pairs in the Parameters input and use the names as variables in the Command Text input.

  5. Set Workflow Output:

    1. Name: Type a name for the output, for example, customersDataTable.

      You will use the name in the client workflow to access the data table.

    2. Value: Set Value to the output of the Run SQL Query activity: =$sqlQuery1.dataTable

  6. Press Ctrl+S to save the workflow.

  7. Open the Info panel and copy the workflow's URL from the Workflow URL box.

    You will need the URL in the next step.

Step 2: Create the client workflow

  1. Create a new client workflow.

  2. Add the following activities and connect them in the given order:

  3. Run Workflow: In the Url input, paste the server workflow's URL.

  4. Press Ctrl+S to save the workflow.

  5. Run the workflow in the Sandbox and press F12 to open the console. To view the data table returned by the query, expand the object named after the Set Workflow Output activity's Name input, for example, customersDataTable.

    This allows you to examine the data table in your browser's console. It also allows you to get the field name to populate the drop-down list.

  6. Display Form:

    1. Double-click the Display Form activity to edit it.

    2. Add a Drop-Down List form element.

    3. Type a title for the drop-down list in the Title box.

    4. In the Options area, select Use a subworkflow from the drop-down list and click OK.
    5. Click Blank to use the Blank template.

      A blank subworkflow opens on the design surface.

    6. Add the following activities and connect them in the given order:

      • Get Form Element Items From Collection (formElementItems1)
      • Set Form Element Items
    7. Get Form Element Items From Collection:

      • Collection: Set the Collection input to =$runWorkflow1.result.Name, where Name is the name that you specified in the Set Workflow Output activity's Name input, for example: =$runWorkflow1.result.customersDataTable

      • Label: Type or paste the name of the field to use to populate the drop-down list.

        You can get the field name from the console.

    8. Set Form Element Items:

      • Items: Set the Items input to the output of the Get Form Element Items From Collection activity: =$formElementItems.items

  7. Press Ctrl+S to save the workflow.

  8. Run the workflow in the Sandbox.

    When the form displays, open the drop-down list to see the field values from the data table. The items in the drop-down list match the column values shown in the console.

© 2019 Latitude Geographics Group Ltd. All Rights Reserved.

Documentation Version 5.11