UserPickList
Node Action:
This node action presents a list of users associated with a tenant as seen from the Access service. The result variable captures the selected user's ID so that it can be used in additional operations, such as assigning tasks.
Parameters:
se_type
UserPickList
se_type = UserPickListse_roles
Collection of roles by which to filter the picklist.
The Assignment ID string is parsed into a Guid and used to search for a valid assignment.
se_determineRoleFilter
Dictionary of role sets used to filter the pick list. Users must possess at least one role in each role set.
se_resultVariable
Name of the result variable to store the data from the node action.
Example:
Reassign Selected Session(s): This example illustrates using the UserPickList node action to prompt the user to select a person to whom the session needs to be reassigned.
digraph workflow {
entry[
label = "Reassign Button"
se_type0 = MultiSessionOperationTrigger
se_displayName0 = "Reassign"
se_sortOrder0 = 10
se_visibilityCondition0 = "(ctx, log) => {
return ctx.Event.isSessionOpen == false;
}"
se_type1 = SessionOperationTrigger
se_displayName1 = "Reassign"
se_sortOrder1 = 50
se_visibilityCondition1 = "(ctx, log) => {
return ctx.Event.isSessionOpen == false;
}"
se_type2 = Action,
se_action2 = "(ctx, log) => {
if(ctx.Event.assignments != null)
{
ctx.State.Assignments = ctx.Event.assignments;
}
else
{
ctx.State.Assignments = new[] {ctx.Event.assignment};
}
}",
]
#Using a Dictionary to hold assignment types avoiding duplicate values.
readAssignmentTypes[
se_type0 = Api,
se_method0 = GET,
se_modifyRequest0 = "(request, ctx, log) => {
request.RequestUri = new Uri($\"api/v1/Kv/Assignments/Types/Editor/?tenantId={ctx.Event.tenantId}\", UriKind.Relative);
}",
se_processResponse0 = "async (response, ctx, log) => {
ctx.State.AssignmentTypes = new Dictionary<string, object>();
var assignmentTypesString = await response.Content.ReadAsStringAsync();
var root = JObject.Parse(assignmentTypesString);
var values = root[\"values\"] as JArray;
foreach (var at in values)
{
string typeName = at[\"value\"][\"name\"].ToString();
if (!string.IsNullOrWhiteSpace(typeName))
{
ctx.State.AssignmentTypes.TryAdd(typeName, at[\"value\"]);
}
}
}",
se_service0 = KvStorage
se_type1 = Api,
se_method1 = GET,
se_modifyRequest1 = "(request, ctx, log) => {
request.RequestUri = new Uri($\"api/v1/Global/Assignments/Types/Editor/?tenantId={ctx.Event.tenantId}\", UriKind.Relative);
}",
se_processResponse1 = "async (response, ctx, log) => {
var assignmentTypesString = await response.Content.ReadAsStringAsync();
var root = JObject.Parse(assignmentTypesString);
var values = root[\"values\"] as JArray;
foreach (var at in values)
{
string typeName = at[\"value\"][\"name\"].ToString();
if (!string.IsNullOrWhiteSpace(typeName))
{
ctx.State.AssignmentTypes.TryAdd(typeName, at[\"value\"]);
}
}
}",
se_service1 = KvStorage
]
selectUser[
se_type0 = UserPickList,
se_resultVariable0 = SelectedUser,
se_determineRoleFilter0 = "(ctx, log) => {
var assignmentTypesToRoles = new Dictionary<string,List<string>>();
foreach (var assignment in ctx.State.Assignments)
{
var typeName = assignment[\"assignmentType\"].ToString();
assignmentTypesToRoles[typeName] = ctx.State.AssignmentTypes[typeName]?[\"customProperties\"]?[\"roles\"].ToObject<List<string>>();
}
ctx.State.AssignmentRoles = assignmentTypesToRoles;
return JToken.FromObject(assignmentTypesToRoles);
}" ]
confirmSelectedUser[
se_type0 = PromptUser,
se_resultVariable0 = ConfirmedSelectedUser,
se_promptCaption0 = "Reassign Confirmation",
se_cardTemplate0 = "{
\"$schema\": \"http://adaptivecards.io/schemas/adaptive-card.json\",
\"type\": \"AdaptiveCard\",
\"version\": \"1.3\",
\"body\": [
{
\"type\": \"TextBlock\",
\"style\":\"heading\",
\"size\": \"large\",
\"text\": \"Confirm Selection: ${selection}\"
},
{
\"type\": \"TextBlock\",
\"style\":\"heading\",
\"text\": \"Are you sure?\"
},
{
\"type\": \"ActionSet\",
\"actions\": [
{
\"type\": \"Action.Submit\",
\"title\": \"Yes\",
\"style\": \"positive\",
\"role\": \"Button\"
},
{
\"type\": \"Action.Submit\",
\"title\": \"No\",
\"style\": \"positive\",
\"role\": \"Button\"
}
]
},
]
}",
se_determineCardData0 = "(ctx, log) => {
var selection = ctx.State.SelectedUser != Guid.Empty.ToString() ? ctx.State.SelectedUser : \"Unassign\";
return JToken.FromObject(new Dictionary<string, object>{{\"selection\", selection}});
}"
]
reassign[
se_executionOrder = ForEach
se_forEachEnumerable = Assignments
se_type0 = Api,
se_method0 = POST
se_modifyRequest0 = "(request, ctx, log) => {
request.RequestUri = new Uri($\"api/v1/assignments/{ctx.State.__currentForEachItem.id}/assign?to={ctx.State.SelectedUser}\", UriKind.RelativeOrAbsolute);
}",
se_resultVariable0 = newAssignment
se_service0 = Editor
]
unassign[
se_executionOrder = ForEach
se_forEachEnumerable = Assignments
se_type0 = Api,
se_method0 = POST
se_modifyRequest0 = "(request, ctx, log) => {
request.RequestUri = new Uri($\"api/v1/assignments/{ctx.State.__currentForEachItem.id}/unassign\", UriKind.RelativeOrAbsolute);
}",
se_resultVariable0 = newAssignment
se_service0 = Editor
]
refreshJobsLists[
se_type0 = refreshMyJobsList;
se_type1 = refreshAvailableJobsList;
se_type2 = refreshAssignedJobsList;
]
notifyUser[
label = "Notify user"
se_type0 = NotifyUser,
se_determineMessage0 = "(ctx, log) => {
return ctx.State.NotifyUserText;
}",
se_notificationType0 = "Information",
se_showToast0 = true
]
exit[
shape=invhouse,
color="#22FF44",
style=filled
]
entry->readAssignmentTypes;
confirmSelectedUser->reassign[
se_type = Condition,
se_condition = "(ctx, log) => {
var result = ctx.State.SelectedUser != null && ctx.State.SelectedUser != Guid.Empty.ToString() && ctx.State.ConfirmedSelectedUser.submittedAction.title == \"Yes\";
if(result)
{
ctx.State.NotifyUserText = $\"Selected sessions now belong to {ctx.State.SelectedUser}.\";
}
return result;
}"
]
confirmSelectedUser->unassign[
se_type = Condition,
se_condition = "(ctx, log) => {
var result = ctx.State.SelectedUser != null && ctx.State.SelectedUser == Guid.Empty.ToString() && ctx.State.ConfirmedSelectedUser.submittedAction.title == \"Yes\";
if(result)
{
ctx.State.NotifyUserText = $\"Selected sessions are now unassigned.\";
}
return result;
}"
]
confirmSelectedUser->selectUser[
se_type = Condition,
se_condition = "(ctx, log) => {
return ctx.State.ConfirmedSelectedUser.submittedAction.title == \"No\" || ctx.State.ConfirmedSelectedUser.submittedAction.title == \"Cancel\";
}"
]
selectUser->confirmSelectedUser[
se_type = Condition,
se_condition = "(ctx, log) => {
return !string.IsNullOrEmpty(ctx.State.SelectedUser);
}"
];
selectUser->exit[
se_type = Condition,
se_condition = "(ctx, log) => {
return string.IsNullOrEmpty(ctx.State.SelectedUser);
}"
]
unassign->refreshJobsLists;
reassign->refreshJobsLists;
refreshJobsLists->notifyUser;
notifyUser->exit
}