RefreshCurrentAssignment
Node Action:
This node action receives an Assignment ID string, converts the ID string into a Guid, searches the My Jobs List for a matching Guid, and sets the matching Assignment Resource as the current assignment.
Parameters:
se_type
RefreshCurrentAssignment
se_type = RefreshCurrentAssignment
se_resultVariable
Name of the result variable to store the data from the node action. The variable is set to true if a refresh is completed.
se_determineAssignmentId
(ctx, log)
=> { return \"assignmentId\"; }
A lambda used to return an Assignment ID string to the node action.
The Assignment ID string is parsed into a Guid and used to search for a valid assignment.
Example:
Refresh Current Assignment: This example illustrates how to retrieve an updated assignment, present the option to take ownership of that assignment, and refresh the current assignment with the updated one. It also accounts for the following scenarios: no open assignments found for the session, the current assignment is already up to date, and the user cancels the option to take ownership of a new assignment.
digraph workflow {
bgcolor="white"
pad=1
splines=ortho;
edge[arrowsize=1, color=black];
node[shape = box];
entry[
se_type0 = SessionToolTrigger,
se_displayName0 = "Refresh Current Assignment ",
se_sortOrder0 = 100,
label = "Refresh Assignment Button",
shape = invhouse,
se_visibilityCondition0 = "(ctx, log) => {
return true;
}",
]
query[
label = "Query API"
se_type0 = Api,
se_method0 = GET,
se_modifyRequest0 = "(request, ctx, log) => {
var q = $\"select * from c where c.tenantId='{ctx.User.TenantId}' and c.associatedSessionId='{ctx.Event.session.id}'\";
request.RequestUri = new Uri($\"api/v1/Assignments/?q={q}\", UriKind.Relative);
}",
se_resultVariable0 = "Assignments",
se_service0 = Editor,
se_type1 = Action,
se_action1 = "(ctx, msLogger) => {
var assignments = ctx.State.Assignments.values.ToObject<List<dynamic>>();
for(int i=0; i<assignments.Count; i++)
{
var s = assignments[i].status.ToString();
if(s.Equals(\"Unassigned\") || s.Equals(\"Assigned\") || s.Equals(\"InProgress\"))
{
ctx.State.Assignment = assignments[i];
break;
}
}
}"
]
promptForTakeOwnership[
label = "Prompt To Take Ownership",
se_type0 = PromptUser,
se_resultVariable0 = TakeOwnershipPromptResponse,
se_promptCaption0 = "New Assignment Available",
se_cardTemplate0 = "{
\"$schema\": \"http://adaptivecards.io/schemas/adaptive-card.json\",
\"type\": \"AdaptiveCard\",
\"version\": \"1.3\",
\"body\": [
{
\"type\": \"TextBlock\",
\"style\":\"heading\",
\"text\": \"An assignment of type ${assignmentType} is available to take over.\"
},
{
\"type\": \"ActionSet\",
\"actions\": [
{
\"type\": \"Action.Submit\",
\"title\": \"Take Ownership\",
\"style\": \"positive\",
\"role\": \"Button\"
},
{
\"type\": \"Action.Submit\",
\"title\": \"Cancel\",
\"style\": \"negative\",
\"role\": \"Button\"
}
]
},
]
}"
se_determineCardData0 = "(ctx, log) => {
var cardData = new Dictionary<string, object>{{\"assignmentType\", ctx.State.Assignment.assignmentType.ToString()}};
return JToken.FromObject(cardData);
}"
]
takeOwnership[
label = "Take Ownership"
se_type0 = Api,
se_method0 = POST
se_modifyRequest0 = "(request, ctx, log) => {
request.RequestUri = new Uri($\"api/v1/Assignments/{ctx.State.Assignment.id}/assign?to={ctx.User.UserId}\", UriKind.RelativeOrAbsolute);
}",
se_resultVariable0 = newAssignment
se_service0 = Editor
]
refreshCurrentAssignment[
label = "Refresh Current Assignment",
color = blue,
se_type0 = RefreshMyJobsList
se_type1 = RefreshCurrentAssignment,
se_determineAssignmentId1 = "(ctx, log) => {
return ctx.State.Assignment.id;
}"
se_resultVariable1 = Refreshed;
]
subgraph cluster_Notifications{
color=yellow
style=bold
margin="20"
bgcolor="white"
label="Notifications"
notifyOfNoneFound[
se_type = NotifyUser,
label = "Notify User of None Found"
se_determineMessage = "(ctx, log) => {
return $\"No active Assignments were found for this session.\";
}",
se_notificationType = "Completed",
se_showToast = true
]
notifyOfCurrent[
se_type = NotifyUser,
label = "Notify User of Current"
se_determineMessage = "(ctx, log) => {
return $\"The current Assignment is already up to date.\";
}",
se_notificationType = "Information",
se_showToast = true
]
notifyOfRefresh[
se_type = NotifyUser,
label = "Notify User of Refresh"
se_determineMessage = "(ctx, log) => {
return $\"The Assignment was successfully refreshed.\";
}",
se_notificationType = "Completed",
se_showToast = true
]
notifyOfFailure[
se_type = NotifyUser,
label = "Notify User of Failure"
se_determineMessage = "(ctx, log) => {
return $\"The Assignment refresh was not completed.\";
}",
se_notificationType = "Alert",
se_showToast = true
]
}
entry->query
query->notifyOfNoneFound[
se_type = Condition,
se_conditionOrder = 1
se_condition = "(ctx, log) => {
return ctx.State.Assignment == null;
}"
]
query->notifyOfCurrent[
se_type = Condition,
se_conditionOrder = 2
se_condition = "(ctx, log) => {
return ctx.State.Assignment == null ? false : ctx.Event.assignment.id.ToString().Equals(ctx.State.Assignment.id.ToString());
}"
]
query->promptForTakeOwnership[
se_type = Condition,
se_conditionOrder = 3
se_condition = "(ctx, log) => {
return ctx.State.Assignment == null ? false : ctx.State.Assignment.status.ToString().Equals(\"Unassigned\");
}"
]
query->refreshCurrentAssignment[
se_type = Condition,
se_conditionOrder = 4
se_condition = "(ctx, log) => {
return ctx.State.Assignment == null ? false : !ctx.State.Assignment.status.ToString().Equals(\"Unassigned\");
}"
]
promptForTakeOwnership->exit[
se_type = Condition,
se_conditionOrder = 1,
se_condition = "(ctx, log) => {
return ctx.State.TakeOwnershipPromptResponse.submittedAction.title == \"Cancel\";
}"
]
promptForTakeOwnership->takeOwnership[
se_type = Condition,
se_conditionOrder = 2,
se_condition = "(ctx, log) => {
return ctx.State.TakeOwnershipPromptResponse.submittedAction.title == \"Take Ownership\";
}"
]
takeOwnership->refreshCurrentAssignment
refreshCurrentAssignment->notifyOfRefresh[
se_type = Condition,
se_conditionOrder = 1,
se_condition = "(ctx, log) => {
return ctx.State.Refreshed;
}"
]
refreshCurrentAssignment->notifyOfFailure[
se_type = Condition,
se_conditionOrder = 2,
se_condition = "(ctx, log) => {
return !ctx.State.Refreshed;
}"
]
notifyOfNoneFound->exit
notifyOfCurrent->exit
notifyOfRefresh->exit
notifyOfFailure->exit
}