I am trying to call a workflow WF1 from another workflow WF2 . I am able to do that and WF1 is getting executed perfectly in the background and returning the desired output through an array of number . Used logs of WF1 to verify that .
But I want to capture the output (array/integer) of WF1 through WF2 . I am unable to get the output (snapshots) through WF2 .
I am attaching the code and log of WF2 . I am attaching the code and log of WF1 as well.
Okay, well, you seem to come across a strange issue... It was frustrating me because your code looks like some re-work of my code here:
How to Retrieve Workflow Execution Details
... If I run MY library workflow that checks workflow tokens, the output is displayed, but every variation I tried of getting the output from the current token item ended in the same result as what you had: null.
So, since checking workflow executions worked rather than the active token, wait until the workflow has completed, then loop through the workflow executions until you find the one with the matching id of the token you just ran.. once you find it, parse the output.
Given the two workflows you attached in the last post, replace the text of your Scriptable task in the "test WF" with the following and run (feel free to remove unneeded code, I left all my test code in place in case something else there may be helpful):
var inputParameters = new Properties();
inputParameters.put("name", name);
System.log("name '" +name);
System.log("hostResource '" +hostResource);
var curToken = wf.execute(inputParameters); //,"root","vmware");
while (curToken.state == "running"){
System.log(".. still running ..");
System.sleep(1000);
}
var tokens = wf.executions;
// Each execution is a "workflowToken" object
for each (token in tokens){
if (token.id == curToken.id && token.isStillValid){
System.log("");
System.log("=============== Checking token ===============");
System.log("Token ID: "+token.id);
System.log("Start Date: "+token.startDate);
if(token.endDate != null){
System.log("End Date: "+token.endDate);
}
System.log("Business State: "+token.businessState); // Indicates the business state as defined by the workflow dev in each of the elements of the workflow (not always specified)
System.log("State: "+token.state); // Indicates the system state of this workflow
/* State values are likely to be one of the following:
waiting <- waiting for user input
failed <- an exception was thrown to cause the workflow to fail
completed <- workflow competed running successfully
canceled <- user right-clicked and canceled the workflow
running <- workflow is still processing
*/
System.log("");
System.log("==== Token Inputs ====");
var inputParams = token.getInputParameters();
if (inputParams != null){
for each (key in inputParams.keys){
var value = inputParams.get(key);
System.log(key + ": " + value + " ("+System.getObjectType(value)+")");
}
}
System.log("");
System.log("==== Token Attributes ====");
var attributes = token.getAttributes();
if(attributes != null){
for each (key in attributes.keys){
var value = attributes.get(key);
System.log(key + ": " + value + " ("+System.getObjectType(value)+")");
}
}
System.log("");
System.log("==== Token Outputs ====");
var outputParams = token.getOutputParameters();
if (outputParams != null){
for each (key in outputParams.keys){
var value = outputParams.get(key);
System.log(key + ": " + value + " ("+System.getObjectType(value)+")");
}
}
System.log("");
System.log("==== Token Log Events ====");
var logEvents = new Array();
logEvents = token.logEvents;
var eventCount = logEvents.length;
System.log("Event Count: "+eventCount);
for (i=eventCount-1; i>-1; i--){
var logEvent = logEvents[i];
System.log("");
System.log(" == EVENT ENTRY "+(eventCount - i)+" == ");
System.log("logTimeStamp: "+logEvent.logTimeStamp);
System.log("longDescription: "+logEvent.longDescription);
System.log("originatorId: "+logEvent.originatorId);
System.log("originatorUri: "+logEvent.originarorUri);
System.log("originatorUserName: "+logEvent.originatorUserName);
System.log("severity: "+logEvent.severity);
System.log("shortDescription: "+logEvent.shortDescription);
}
}
}
And for an idea of the output, my logs tab looked like this:
[2014-08-01 16:29:25.632] [I] name 'demo
[2014-08-01 16:29:25.632] [I] hostResource 'null
[2014-08-01 16:29:26.351] [I] .. still running ..
[2014-08-01 16:29:27.365] [I]
[2014-08-01 16:29:27.365] [I] =============== Checking token ===============
[2014-08-01 16:29:27.365] [I] Token ID: ff80808146af57140147934349c10567
[2014-08-01 16:29:27.365] [I] Start Date: 2014-08-01 16:29:26
[2014-08-01 16:29:27.365] [I] End Date: 2014-08-01 16:29:26
[2014-08-01 16:29:27.365] [I] Business State: null
[2014-08-01 16:29:27.367] [I] State: completed
[2014-08-01 16:29:27.367] [I]
[2014-08-01 16:29:27.367] [I] ==== Token Inputs ====
[2014-08-01 16:29:27.371] [I] name: demo (string)
[2014-08-01 16:29:27.371] [I]
[2014-08-01 16:29:27.371] [I] ==== Token Attributes ====
[2014-08-01 16:29:27.374] [I] restOperation: null (null)
[2014-08-01 16:29:27.374] [I] statusCodeAttribute: null (null)
[2014-08-01 16:29:27.374] [I] snapshotids: null (null)
[2014-08-01 16:29:27.374] [I] RESTHost: null (null)
[2014-08-01 16:29:27.375] [I] hostResource: null (null)
[2014-08-01 16:29:27.375] [I] errorCode: (string)
[2014-08-01 16:29:27.375] [I]
[2014-08-01 16:29:27.375] [I] ==== Token Outputs ====
[2014-08-01 16:29:27.378] [I] snapshots: 1966,2262,2555,2927,3272,3586,3895,3903,3909,3987,4041,4430,4734,5048 (Array)
[2014-08-01 16:29:27.378] [I]
[2014-08-01 16:29:27.378] [I] ==== Token Log Events ====
[2014-08-01 16:29:27.423] [I] Event Count: 2
[2014-08-01 16:29:27.423] [I]
[2014-08-01 16:29:27.423] [I] == EVENT ENTRY 1 ==
[2014-08-01 16:29:27.423] [I] logTimeStamp: 2014-08-01 16:29:26.364
[2014-08-01 16:29:27.423] [I] longDescription: Workflow has started
[2014-08-01 16:29:27.423] [I] originatorId: a4e950d3-c575-4ddd-8b7f-dd838cdf7b2e
[2014-08-01 16:29:27.423] [I] originatorUri: undefined
[2014-08-01 16:29:27.423] [I] originatorUserName: bazbill
[2014-08-01 16:29:27.424] [I] severity: 0
[2014-08-01 16:29:27.424] [I] shortDescription: Workflow has started
[2014-08-01 16:29:27.424] [I]
[2014-08-01 16:29:27.424] [I] == EVENT ENTRY 2 ==
[2014-08-01 16:29:27.424] [I] logTimeStamp: 2014-08-01 16:29:26.401
[2014-08-01 16:29:27.424] [I] longDescription: Workflow is completed
[2014-08-01 16:29:27.424] [I] originatorId: a4e950d3-c575-4ddd-8b7f-dd838cdf7b2e
[2014-08-01 16:29:27.424] [I] originatorUri: undefined
[2014-08-01 16:29:27.425] [I] originatorUserName: bazbill
[2014-08-01 16:29:27.425] [I] severity: 0
[2014-08-01 16:29:27.425] [I] shortDescription: Workflow is completed
It would be more effective to add your workflow(s) to a vCO Package, export the package, and attach that to your help requests... screenshots and txt files, while providing the content, are excess work for us to parse through and put into workflows ourselves. Everyone contributing here does so on the little bit of free/personal time they have.
That being said, I'm not going to put all your stuff in a workflow to figure out what your missing, but off the top of my head, you need:
WF3: First element in here is WF1. Outputs of WF1 need to be bound to Attributes of WF3. Next element can be WF2, which can get its inputs from either those attributes or from the WF3 inputs.
Any inputs to WF3 can be passed in to the child workflows (WF1 / WF2).
Please be sure to watch the videos at http://www.vmwarelearning.com/orchestrator .
Hello
My apologies since I am new to this technology and the community , I was not aware of the protocol .
I have exported the workflows to the package and reattached the attachment .
Just FYI : I am monitoring the token state and used getOutParameters .
Get The list of Snapshots ....--> WF1
Test_WF ---> WF2
Thanks in advance for your guidance
Okay, well, you seem to come across a strange issue... It was frustrating me because your code looks like some re-work of my code here:
How to Retrieve Workflow Execution Details
... If I run MY library workflow that checks workflow tokens, the output is displayed, but every variation I tried of getting the output from the current token item ended in the same result as what you had: null.
So, since checking workflow executions worked rather than the active token, wait until the workflow has completed, then loop through the workflow executions until you find the one with the matching id of the token you just ran.. once you find it, parse the output.
Given the two workflows you attached in the last post, replace the text of your Scriptable task in the "test WF" with the following and run (feel free to remove unneeded code, I left all my test code in place in case something else there may be helpful):
var inputParameters = new Properties();
inputParameters.put("name", name);
System.log("name '" +name);
System.log("hostResource '" +hostResource);
var curToken = wf.execute(inputParameters); //,"root","vmware");
while (curToken.state == "running"){
System.log(".. still running ..");
System.sleep(1000);
}
var tokens = wf.executions;
// Each execution is a "workflowToken" object
for each (token in tokens){
if (token.id == curToken.id && token.isStillValid){
System.log("");
System.log("=============== Checking token ===============");
System.log("Token ID: "+token.id);
System.log("Start Date: "+token.startDate);
if(token.endDate != null){
System.log("End Date: "+token.endDate);
}
System.log("Business State: "+token.businessState); // Indicates the business state as defined by the workflow dev in each of the elements of the workflow (not always specified)
System.log("State: "+token.state); // Indicates the system state of this workflow
/* State values are likely to be one of the following:
waiting <- waiting for user input
failed <- an exception was thrown to cause the workflow to fail
completed <- workflow competed running successfully
canceled <- user right-clicked and canceled the workflow
running <- workflow is still processing
*/
System.log("");
System.log("==== Token Inputs ====");
var inputParams = token.getInputParameters();
if (inputParams != null){
for each (key in inputParams.keys){
var value = inputParams.get(key);
System.log(key + ": " + value + " ("+System.getObjectType(value)+")");
}
}
System.log("");
System.log("==== Token Attributes ====");
var attributes = token.getAttributes();
if(attributes != null){
for each (key in attributes.keys){
var value = attributes.get(key);
System.log(key + ": " + value + " ("+System.getObjectType(value)+")");
}
}
System.log("");
System.log("==== Token Outputs ====");
var outputParams = token.getOutputParameters();
if (outputParams != null){
for each (key in outputParams.keys){
var value = outputParams.get(key);
System.log(key + ": " + value + " ("+System.getObjectType(value)+")");
}
}
System.log("");
System.log("==== Token Log Events ====");
var logEvents = new Array();
logEvents = token.logEvents;
var eventCount = logEvents.length;
System.log("Event Count: "+eventCount);
for (i=eventCount-1; i>-1; i--){
var logEvent = logEvents[i];
System.log("");
System.log(" == EVENT ENTRY "+(eventCount - i)+" == ");
System.log("logTimeStamp: "+logEvent.logTimeStamp);
System.log("longDescription: "+logEvent.longDescription);
System.log("originatorId: "+logEvent.originatorId);
System.log("originatorUri: "+logEvent.originarorUri);
System.log("originatorUserName: "+logEvent.originatorUserName);
System.log("severity: "+logEvent.severity);
System.log("shortDescription: "+logEvent.shortDescription);
}
}
}
And for an idea of the output, my logs tab looked like this:
[2014-08-01 16:29:25.632] [I] name 'demo
[2014-08-01 16:29:25.632] [I] hostResource 'null
[2014-08-01 16:29:26.351] [I] .. still running ..
[2014-08-01 16:29:27.365] [I]
[2014-08-01 16:29:27.365] [I] =============== Checking token ===============
[2014-08-01 16:29:27.365] [I] Token ID: ff80808146af57140147934349c10567
[2014-08-01 16:29:27.365] [I] Start Date: 2014-08-01 16:29:26
[2014-08-01 16:29:27.365] [I] End Date: 2014-08-01 16:29:26
[2014-08-01 16:29:27.365] [I] Business State: null
[2014-08-01 16:29:27.367] [I] State: completed
[2014-08-01 16:29:27.367] [I]
[2014-08-01 16:29:27.367] [I] ==== Token Inputs ====
[2014-08-01 16:29:27.371] [I] name: demo (string)
[2014-08-01 16:29:27.371] [I]
[2014-08-01 16:29:27.371] [I] ==== Token Attributes ====
[2014-08-01 16:29:27.374] [I] restOperation: null (null)
[2014-08-01 16:29:27.374] [I] statusCodeAttribute: null (null)
[2014-08-01 16:29:27.374] [I] snapshotids: null (null)
[2014-08-01 16:29:27.374] [I] RESTHost: null (null)
[2014-08-01 16:29:27.375] [I] hostResource: null (null)
[2014-08-01 16:29:27.375] [I] errorCode: (string)
[2014-08-01 16:29:27.375] [I]
[2014-08-01 16:29:27.375] [I] ==== Token Outputs ====
[2014-08-01 16:29:27.378] [I] snapshots: 1966,2262,2555,2927,3272,3586,3895,3903,3909,3987,4041,4430,4734,5048 (Array)
[2014-08-01 16:29:27.378] [I]
[2014-08-01 16:29:27.378] [I] ==== Token Log Events ====
[2014-08-01 16:29:27.423] [I] Event Count: 2
[2014-08-01 16:29:27.423] [I]
[2014-08-01 16:29:27.423] [I] == EVENT ENTRY 1 ==
[2014-08-01 16:29:27.423] [I] logTimeStamp: 2014-08-01 16:29:26.364
[2014-08-01 16:29:27.423] [I] longDescription: Workflow has started
[2014-08-01 16:29:27.423] [I] originatorId: a4e950d3-c575-4ddd-8b7f-dd838cdf7b2e
[2014-08-01 16:29:27.423] [I] originatorUri: undefined
[2014-08-01 16:29:27.423] [I] originatorUserName: bazbill
[2014-08-01 16:29:27.424] [I] severity: 0
[2014-08-01 16:29:27.424] [I] shortDescription: Workflow has started
[2014-08-01 16:29:27.424] [I]
[2014-08-01 16:29:27.424] [I] == EVENT ENTRY 2 ==
[2014-08-01 16:29:27.424] [I] logTimeStamp: 2014-08-01 16:29:26.401
[2014-08-01 16:29:27.424] [I] longDescription: Workflow is completed
[2014-08-01 16:29:27.424] [I] originatorId: a4e950d3-c575-4ddd-8b7f-dd838cdf7b2e
[2014-08-01 16:29:27.424] [I] originatorUri: undefined
[2014-08-01 16:29:27.425] [I] originatorUserName: bazbill
[2014-08-01 16:29:27.425] [I] severity: 0
[2014-08-01 16:29:27.425] [I] shortDescription: Workflow is completed
Thank you for your guidance .It has worked . Have a Great Weekend !! ![]()
