I wish to print the full Category path of currently running WF from inside its scripting element.
var currentWFName = workflow.name ;
var WFCategories = Server.getAllWorkflowCategories();
for each (var WFCategory in WFCategories){
for each (var WF in WFCategory.allWorkflows){
if(WF.name == currentWFName){
System.log(WF.workflowCategory.path + "/" + WF.name);
}
}
}
Slightly improved / simplified version where we get the Server to do the lookup
var id = workflow.currentWorkflow.id;
var wfInstance = Server.getWorkflowWithId(id);
var catObj = wfInstance.workflowCategory;
System.log(catObj.path + "/" + wfInstance.name);
Should be a little quicker
var currentWFName = workflow.name ;
var WFCategories = Server.getAllWorkflowCategories();
for each (var WFCategory in WFCategories){
for each (var WF in WFCategory.allWorkflows){
if(WF.name == currentWFName){
System.log(WF.workflowCategory.path + "/" + WF.name);
}
}
}
Slightly improved / simplified version where we get the Server to do the lookup
var id = workflow.currentWorkflow.id;
var wfInstance = Server.getWorkflowWithId(id);
var catObj = wfInstance.workflowCategory;
System.log(catObj.path + "/" + wfInstance.name);
Should be a little quicker
eoinbyrne - apart from being improved / simplified version, your code is also correct , which is not the case for the code provided by imtrinity94
The problems in his code:
iiliev Is there a way to get the workflow item name inside the same scriptable task? (For eg, item0 is a scriptable tasks with name = Rename a VM)