Api
Node Action:
The Api node action makes an HTTP call. It assumes a JSON rest request but the request can be modified by the workflow. A service call that respects tenant boundaries can also be called.
Parameters:
se_type
Api
se_type = Apise_uri
The URI to which the request is sent.
se_resultVariable
The string response to be returned from this action.
se_body
The content body for the HTTP request.
se_method
The HTTP method for the request.
se_modifyRequest
A lambda to modify the HTTP request.
se_processResponse
A lambda to process the response before setting it to the resultVariable.
se_service
A service name to which to make a request (e.g., DesignerCoordination).
Example:
Find Design To Assign: The following workflow allows you to search a design and assign it to a designer.
digraph workflow {
splines=spline;
edge[arrowsize=1, color=black];
node[shape = box, color = green];
entry[
label = "Find a design to assign",
shape= invhouse,
height = 1,
se_type0 = DesignToolTrigger,
se_deferUntilOnline0 = false,
se_displayName0 = "Find Design to Assign"
se_iconService0 = ""
se_iconUrl0 = ""
se_requiresConnection0 = true,
se_visibilityCondition0 = "(ctx, msLogger) => {
return ctx.User.Roles.Any(p => p == \"Designer.Approval\");
}",
se_type1 = CompleteAssignmentTrigger,
se_displayName1 = ""
se_iconService1 = ""
se_iconUrl1 = ""
se_requiresConnection1 = false,
se_sortOrder1 = 0,
se_visibilityCondition1 = "(dynamicStateMachineContext, msLogger) => {
return false;
}",
];
exit[
label = "Complete"
shape=invhouse,
color="#22FF44",
style=filled
]
requestSearchTerm[
se_type0 = PromptUser,
se_cardTemplate0 = "{
\"type\": \"AdaptiveCard\",
\"body\": [
{
\"type\": \"TextBlock\",
\"size\": \"Medium\",
\"weight\": \"Bolder\",
\"text\": \"Search For a Design\"
},
{
\"type\": \"ColumnSet\",
\"columns\": [
{
\"type\": \"Column\",
\"width\": \"stretch\",
\"items\": [
{
\"type\": \"Input.Text\",
\"placeholder\": \"\",
\"id\": \"searchTerm\",
}
]
}
]
}
],
\"actions\": [
{
\"type\": \"Action.Submit\",
\"title\": \"Search\",
\"style\": \"positive\",
\"role\": \"Button\"
}
],
\"$schema\": \"http://adaptivecards.io/schemas/adaptive-card.json\",
\"version\": \"1.3\"
}",
se_resultVariable0 = SearchTerm,
]
performQuery[
label = "Perform Query"
se_type0 = CopyToClipboard,
se_determineData0 = "(ctx, log) => {
return JsonConvert.SerializeObject(ctx);
}",
se_type1 = Api,
se_method1 = GET,
se_modifyRequest1 = "(request, ctx, log) => {
var searchFormat = \"CONTAINS(c.name, '{0}', true) or CONTAINS(c.id,'{0}', true) or CONTAINS(c.notes,'{0}', true) or CONTAINS (c.assignedTo, '{0}', true)\";
var query = System.Net.WebUtility.UrlEncode(string.Format(searchFormat, ctx.State.SearchTerm.userInputs.searchTerm));
var uri = new Uri($\"api/v1/query?q=select+*+from+c+where+({query})+order+by+c.dateModified+desc&tenantId=OrbitTest&pageSize=50&walkAncestry=True&walkReferenceDesigns=False\", UriKind.RelativeOrAbsolute);
request.RequestUri = uri;
}",
se_resultVariable1 = SearchResults,
se_service1 = DesignerCoordination,
se_type2 = CopyToClipboard,
se_determineData2 = "(ctx, log) => {
var packetsOfData = new List<JObject>();
foreach(var assignment in ((IEnumerable<dynamic>)ctx.State.SearchResults.assignments)){
var design = ((IEnumerable<dynamic>)ctx.State.SearchResults.designs).FirstOrDefault(d => d.id == assignment.designId);
var workRequest = design == null ? null : ((IEnumerable<dynamic>)ctx.State.SearchResults.workRequests).FirstOrDefault(w => w.id == design.workRequestId);
packetsOfData.Add(JObject.FromObject(new {
assignment = assignment,
design = design,
workRequest = workRequest
}));
}
ctx.State.PacketsOfData = packetsOfData;
return JsonConvert.SerializeObject(ctx.State.PacketsOfData);
}",
]
promptToSelectDesign[
label = "Prompt for design selection",
se_type0 = PromptUser,
se_cardTemplate0 = "{
\"$schema\": \"http://adaptivecards.io/schemas/adaptive-card.json\",
\"type\": \"AdaptiveCard\",
\"version\": \"1.3\",
\"body\": [
{
\"type\": \"TextBlock\",
\"text\": \"Which design would you like to assign?\"
},
{
\"type\": \"Input.ChoiceSet\",
\"id\": \"ChosenAssignment\",
\"choices\": [
{
\"title\": \"${Key}\",
\"value\": \"${Value}\",
\"$data\": \"${$root['results']}\"
}
]
}
],
\"actions\": [
{
\"type\": \"Action.Submit\",
\"title\": \"Assign To Me\",
\"style\": \"positive\",
\"role\": \"Button\"
},
{
\"type\": \"Action.Submit\",
\"title\": \"Assign To...\",
\"style\": \"positive\",
\"role\": \"Button\"
}
]
}",
se_determineCardData0 = "(ctx, log) => {
var packetsOfData = ((IEnumerable<JObject>)ctx.State.PacketsOfData).Cast<JObject>().ToList();
var obj = new {
results = new KeyValuePair<string,dynamic>[packetsOfData.Count]
};
for(int i = 0; i < packetsOfData.Count; i++){
dynamic packet = (JObject)packetsOfData[i];
obj.results[i] = new KeyValuePair<string,dynamic>($\"({packet.assignment.assignmentType}) - {(packet.design.Type == JTokenType.Null ? null : packet.design?.name)}\", packet.assignment.id.ToString());
}
return obj;
}",
se_resultVariable0 = SelectedAssignment
]
assignTo[
label = "Prompt for assignment"
se_type0 = UserPickList,
se_resultVariable0 = SelectedUserId
se_roles0 = "Designer.Approval,Designer.ElectricDesigner"
]
assign[
label = "Assign"
se_type1 = Api,
se_method1 = POST,
se_modifyRequest1 = "(request, ctx, log) => {
var body = new {
assignedTo = ctx.State.SelectedUserId
};
request.Content = new StringContent(JsonConvert.SerializeObject(body), Encoding.UTF8, \"application/json\");
var uri = new Uri($\"api/v1/assignment/{ctx.State.SelectedAssignment.userInputs.ChosenAssignment}/assign\", UriKind.RelativeOrAbsolute);
request.RequestUri = uri;
}",
se_resultVariable1 = SearchResults,
se_service1 = DesignerCoordination,
se_type2 = RefreshWorkList
]
cancel[
label= "Cancelled",
shape=invhouse,
color=yellow,
style=filled
]
entry->requestSearchTerm[
]
requestSearchTerm->cancel[
se_type = Condition,
se_condition = "(ctx, log) => {
return ctx.State.SearchTerm.submittedAction.title != \"Search\";
}"
]
requestSearchTerm->performQuery[
se_type = Condition,
se_condition = "(ctx, log) => {
return ctx.State.SearchTerm.submittedAction.title == \"Search\";
}"
]
performQuery->promptToSelectDesign[
]
promptToSelectDesign->cancel[
se_type = Condition,
se_condition = "(ctx, log) => {
return ctx.State.SearchTerm.submittedAction.title != \"Search\";
}"
]
promptToSelectDesign->assign[
xlabel = "Assign to me",
se_type = Condition,
se_condition = "(ctx, log) => {
var result = ctx.State.SelectedAssignment.submittedAction.title == \"Assign To Me\";
if(result)
{
ctx.State.SelectedUserId = ctx.User.UserId;
}
return result;
}"
]
promptToSelectDesign->assignTo[
se_type = Condition,
se_condition = "(ctx, log) => {
return ctx.State.SelectedAssignment.submittedAction.title == \"Assign To...\";
}"
]
assignTo->assign[
se_type = Condition,
se_condition = "(ctx, log) => {
return ctx.State.SelectedUserId != null;
}"
]
assignTo->cancel[
se_type = Condition,
se_condition = "(ctx, log) => {
return ctx.State.SelectedUserId == null;
}"
]
assign->exit[
]
}