WorkflowStage
WorkflowStage
WorkflowStage holds one stage of a workflow: its name, color, the users and roles who work on it, and the stages an entry can move to next. Add stages to WorkflowModel.WorkflowStages.
When to Use This Class: Use this class to define each stage when you create or update a workflow.
Conceptual Role: Acts as the item type of WorkflowModel.WorkflowStages. The SDK serializes the list under the workflow_stages key.
Returns: WorkflowStage. One stage of a workflow.
Properties
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
| Uid | string? | No | null | UID of the stage. The API sets it when it creates the stage. Serialized as uid. |
| Name | string? | No | null | Name of the stage. Serialized as name. |
| Color | string? | No | null | Display color of the stage, as a hex code such as #2196f3. Serialized as color. |
| SystemACL | Dictionary<string, object>? | No | null | Roles, users, and others who can work on entries in the stage. Serialized as SYS_ACL. |
| NextAvailableStages | List<string>? | No | null | UIDs of the stages an entry can move to next. Serialized as next_available_stages. |
| AllStages | bool | No | true | Serialized as allStages. |
| AllUsers | bool | No | true | Serialized as allUsers. |
| SpecificStages | bool | No | false | Serialized as specificStages. |
| SpecificUsers | bool | No | false | Serialized as specificUsers. |
| EntryLock | string? | No | null | Controls who can edit an entry in this stage. Serialized as entry_lock. |
Class-Level Notes
What the SDK sends.
- The SDK leaves every null property out of the request body and always sends the four bool properties.
- The JSON keys mix three naming styles. SystemACL serializes as SYS_ACL, the four bool properties use camel case (allStages), and the rest use snake case (next_available_stages).
- The SDK sends SystemACL as you build it and does not check its shape.
Additional Resource Refer to Create a workflow for the stage fields the API accepts.
Method Index
WorkflowStage has no methods. Add it to WorkflowModel.WorkflowStages and pass the model to the Create or Update method of Workflow.
Class-Level Snippet
This snippet builds a stage that every user can work on, adds it to a workflow, and creates the workflow.
using System;
using System.Collections.Generic;
using Contentstack.Management.Core;
using Contentstack.Management.Core.Exceptions;
using Contentstack.Management.Core.Models;
ContentstackClient client = new ContentstackClient("<AUTHTOKEN>");
WorkflowStage review = new WorkflowStage()
{
Name = "Review",
Color = "#ff9800",
NextAvailableStages = new List<string> { "$all" },
EntryLock = "$none",
SystemACL = new Dictionary<string, object>
{
["roles"] = new Dictionary<string, object> { ["uids"] = new List<string>() },
["users"] = new Dictionary<string, object> { ["uids"] = new List<string> { "$all" } },
["others"] = new Dictionary<string, object>()
}
};
WorkflowModel model = new WorkflowModel()
{
Name = "Editorial Review",
ContentTypes = new List<string> { "blog_post" },
WorkflowStages = new List<WorkflowStage> { new WorkflowStage() { Name = "Draft", Color = "#2196f3" }, review }
};
try
{
ContentstackResponse response = client.Stack("<API_KEY>").Workflow().Create(model);
Console.WriteLine(response.OpenJsonObjectResponse()["workflow"]?["workflow_stages"]?.ToJsonString());
}
catch (ContentstackErrorException e)
{
Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.ErrorMessage}");
}