Create an Activity

This article will walk you through creating a new workflow activity for Geocortex Workflow Server.

Prerequisites

important

Extending Geocortex Workflow with server side components requires an on-premises installation of Geocortex Workflow. You will need administrative access to this installation.

Follow the instructions in the Geocortex Workflow Server page to set up your development environment and Geocortex Workflow Server extension project.

note

A working knowledge of C# and .NET Standard is recommended before extending Geocortex Workflow Server

Create the Activity

  1. Create a new file CustomActivity.cs in the root of your Geocortex Workflow Server extension project.
  2. Add a new skeleton workflow activity that implements IActivityHandler.
App1/App1/CustomActivity.cs
using Geocortex.Workflow.Runtime;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace App1.Workflow
{
public class CustomActivity : IActivityHandler
{
public static string Action { get; } = "your:unique:namespace::CustomActivity";
public Task<IDictionary<string, object>> Execute(IDictionary<string, object> inputs, IActivityContext context)
{
return Task.FromResult((IDictionary<string, object>)new Dictionary<string, object>(){
["test"] = "value"
});
}
}
}

Register the Activity with an Assembly Attribute

  1. Create a new file, Properties\AssemblyInfo.cs
  2. Add the custom Geocortex Workflow attribute to AssemblyInfo.cs:
App1/App1/Properties/AssemblyInfo.cs
[assembly: Geocortex.Workflow.Runtime.WorkflowActivities]

This registers the assembly to a namespace that Geocortex Workflow Server can discover.

note

By convention, assembly attributes are typically added to a file called "Properties\AssemblyInfo.cs", but they can be added to any code file.

Deploy the Activity

Follow the instructions to deploy Geocortex Workflow Server activities.

Use the Activity in a Workflow

Server workflows that run on your Geocortex Workflow Server deployment can now run this custom activity.

tip

Registering stubs for .NET activities provides a user friendly interface for your custom activities in Geocortex Workflow Designer.

You can run the custom activity by referencing it by action with the RunActivity activity. The custom activity created in this article takes no inputs but produces an output with the property "test".