AssignUser

View as Markdown

AssignUser

AssignToUser identifies one user that a workflow stage assigns to an entry. You add it to the AssignedTo list of an EntryWorkflowStage.

When to Use This Class: Use this class when SetWorkflow should assign the entry to a specific user.

Conceptual Role: Acts as the data model that the SDK sends as one item of the assigned_to array in a set entry workflow stage request.

Returns: AssignToUser. One assigned user.

Properties

NameTypeRequiredDefaultDescription
Uidstring?NonullUID of the user. Sent as uid.
Namestring?NonullName of the user. Sent as name.
Emailstring?NonullEmail address of the user. Sent as email.

Class-Level Notes

What the SDK sends.

  • The SDK sends every property that is not null and checks none of them.
  • The Content Management API (CMA) reference asks for the user details, such as UID, name, and email. See Set entry workflow stage.

Method Index

AssignToUser has no methods. Set its properties and add it to EntryWorkflowStage.AssignedTo.

Class-Level Snippet

The snippet below assigns an entry to one user at a workflow stage.

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>");

EntryWorkflowStage stage = new EntryWorkflowStage
{
    Uid = "<WORKFLOW_STAGE_UID>",
    AssignedTo = new List<AssignToUser>
    {
        new AssignToUser { Uid = "<USER_UID>", Name = "Jane Doe", Email = "<EMAIL>" }
    }
};

try
{
    ContentstackResponse response = client.Stack("<API_KEY>").ContentType("<CONTENT_TYPE_UID>").Entry("<ENTRY_UID>").SetWorkflow(stage);
    Console.WriteLine(response.OpenJsonObjectResponse()["notice"]);
}
catch (ContentstackErrorException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.ErrorMessage}");
}