I'm trying to get the total items for a switch element.
I don't know how to get all the elements for a switch, but I do know how to get the names of all the elements in the current workflow, and I want to filter out all the script tasks that call the 'clear' script task.
This is my code:
System.log(workflow.rootWorkflow.name)
System.log(workflow.rootWorkflow.description)
System.log("# items: " + workflow.rootWorkflow.numberOfItem)
var items = workflow.rootWorkflow.items;
for each (var item in items) {
System.log(">>> stack entry begin: "+ item.name );
System.log(">>> stack: "+ item.description );
System.log("next: " + item.nextItem);
//Erro
//System.log("next: " + item.nextItem.name);
}
Thanks
Hello @goraut,
welcome in the VMware Community.
You ask a very interesting question. The WorkflowSwitchItem is not documented in the Orchestrator API Explorer. As far as I can see it contains two methods outItems and conditions.
System.log(workflow.rootWorkflow.name)
System.log(workflow.rootWorkflow.description)
System.log("# items: " + workflow.rootWorkflow.numberOfItem)
var items = workflow.rootWorkflow.items;
for each (var item in items) {
System.log(">>> stack entry begin: "+ item.name );
System.log(">>> stack: "+ item.description );
System.log("next: " + item.nextItem);
//Erro
//System.log("next: " + item.nextItem.name);
if (item.constructor.name === "WorkflowSwitchItem") {
item.outItems.forEach( function(outItem) {
System.log(outItem.name);
});
item.conditions.forEach( function(condition) {
System.log(condition);
});
}
}
outItems delivers an array of workflow items of the switch element and conditions delivers an array of strings with the conditions.
To get the total count of items for the switch element you can use
item.outItems.length
Best regards
Stefan
Hello @goraut,
welcome in the VMware Community.
You ask a very interesting question. The WorkflowSwitchItem is not documented in the Orchestrator API Explorer. As far as I can see it contains two methods outItems and conditions.
System.log(workflow.rootWorkflow.name)
System.log(workflow.rootWorkflow.description)
System.log("# items: " + workflow.rootWorkflow.numberOfItem)
var items = workflow.rootWorkflow.items;
for each (var item in items) {
System.log(">>> stack entry begin: "+ item.name );
System.log(">>> stack: "+ item.description );
System.log("next: " + item.nextItem);
//Erro
//System.log("next: " + item.nextItem.name);
if (item.constructor.name === "WorkflowSwitchItem") {
item.outItems.forEach( function(outItem) {
System.log(outItem.name);
});
item.conditions.forEach( function(condition) {
System.log(condition);
});
}
}
outItems delivers an array of workflow items of the switch element and conditions delivers an array of strings with the conditions.
To get the total count of items for the switch element you can use
item.outItems.length
Best regards
Stefan
Thanks @StefanSchnell