Complete an Instance Step
Complete an instance step that is currently Active
. If the step is configured with output fields, you can set the values of those output fields while completing the step.
Permissions Required
You must have admin access to the Instance, or be an assignee for the Step for this request to succeed
Method Signature
InstanceStep CompleteStep(Guid id, IEnumerable<KeyValuePair<string, object>> fields = null);
async Task<InstanceStep> CompleteStepAsync(Guid id, IEnumerable<KeyValuePair<string, object>> fields = null);
Parameters
Parameter | Type | Description |
---|---|---|
id | Guid | The ID of the Instance Step to complete |
fields | IEnumerable<KeyValuePair<string, object>> | Optional named fields to set on the InstanceStep. Must match Fields configured on the InstanceStep. |
returns | InstanceStep | The completed Instance Step |
InstanceStep CompleteStep(string id, IEnumerable<KeyValuePair<string, object>> fields = null);
async Task<InstanceStep> CompleteStepAsync(string id, IEnumerable<KeyValuePair<string, object>> fields = null);
Parameter | Type | Description |
---|---|---|
id | string | The ID of the Instance Step to complete |
fields | IEnumerable<KeyValuePair<string, object>> | Optional named fields to set on the InstanceStep. Must match Fields configured on the InstanceStep. |
returns | InstanceStep | The completed Instance Step |
InstanceStep CompleteStep(CompleteStepRequest stepRequest);
async Task<InstanceStep> CompleteStepAsync(CompleteStepRequest stepRequest);
Parameter | Type | Description |
---|---|---|
stepRequest | CompleteStepRequest | Specifies the output fields to set when completing the step |
Example
/*
* Demonstrates starting a Workflow Instance, then completing
* a Step in that Instance. Both text and file fields are
* set during task completion.
*/
using Catalytic.Sdk;
using Catalytic.Sdk.Entities;
using System;
using System.IO;
namespace Catalytic.Sdk.Examples
{
class Program
{
// update this to your email before running this sample
public const string YourEmail = "[email protected]";
static void Main(string[] args)
{
// create and initialize the Catalytic SDK Client
var catalytic = new CatalyticClient(Credentials.Default);
// Get the workflow
var workflow = catalytic.Workflows.Get("c9f2beec-10c0-4f2f-b4e0-1d884c7e053c");
// Set the inputs the Workflow expects
var request = workflow
.SetInput("Age", 42)
.SetInput("Name", "Alice")
.SetName($"SDK Example - {DateTimeOffset.Now.ToString()}");
// Start the workflow
var instance = catalytic.Instances.Start(request);
// get the step we want to complete
var steps = catalytic.Instances.GetSteps(instance.InstanceId).Steps;
var uploadStep = steps.Where(
s => s.Name == "Upload Updated Spreadsheet and Set Email").First();
// download the Data Table from the "Table" field as a CSV
var tableId = instance.Fields["Table"].GetValue<Guid>();
var csvFile = catalytic.DataTables.DownloadFile(tableId, DataTableExportFormat.CSV);
// Do our "business logic" to transform the csv data
// As a simple example, we replace "Foo" with "Bar"
var updatedCsvContent = csvFile.OpenText().ReadToEnd().Replace("Foo", "Bar");
// create the output csv file locally
var updatedCsvFile = new FileInfo(Path.GetTempFileName());
File.WriteAllText(updatedCsvFile.FullName, updatedCsvContent);
// To complete the step, we will set both a text and a file field
var stepRequest = step
.SetInput("Updated CSV", updatedCsvFile)
.SetInput("Email Address", YourEmail);
catalytic.Instances.CompleteStep(stepRequest);
Console.WriteLine($"You should have an email waiting for you at {YourEmail} now with the updated CSV converted to an Excel attachment");
}
}
}
Updated almost 3 years ago