VMware Cloud Community
oscaralvarez
Enthusiast
Enthusiast
Jump to solution

Getting the input values from a workflow in a Task.

Having task as a valid Task object I'm able to list the parameter keys names for a Tasked Workflow

var parameters = task.parameters;

var keys = parameters.keys;

for (var x=0;x<keys.length;x++) {

System.log(keys[x]);}

But how can I get the assigned values in the Task for each one of that input keys????  

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
oscaralvarez
Enthusiast
Enthusiast
Jump to solution

Finally i managed to do it this way :

var parameters = tasks.parameters;

var keys = parameters.keys;

for (var x=0;x<keys.length;x++) {

System.log("  key : " + keys[x]);

System.log (" value : " + parameters.get(keys[x]));

System.log("   ");

Thank you!!

Oscar

View solution in original post

0 Kudos
3 Replies
iiliev
VMware Employee
VMware Employee
Jump to solution

First, you need to get a corresponding workflow token object. This can be done via property executions of the task objects, which returns an array with all executions/tokens fr this task, and you can pick one of these executions.

Then having the workflow token object (of type WorkflowToken), you can get the runtime parameters via its attributesStack property, which returns array of array (two-dimensional array) of objects of type Attribute. Each instance of this attribute has name and value properties.

Let me know if you have problems writing scripting code to iterate over attribute stack and fetching the runtime values using the above description.

0 Kudos
oscaralvarez
Enthusiast
Enthusiast
Jump to solution

The issue is that i want to use that for Tasks which hasn't been executed ever... that why I can not get a Workflow token. So these details should be obtained from the Task object, in a similar way i got the variable names i should get the variable values.

Any clue?

0 Kudos
oscaralvarez
Enthusiast
Enthusiast
Jump to solution

Finally i managed to do it this way :

var parameters = tasks.parameters;

var keys = parameters.keys;

for (var x=0;x<keys.length;x++) {

System.log("  key : " + keys[x]);

System.log (" value : " + parameters.get(keys[x]));

System.log("   ");

Thank you!!

Oscar

0 Kudos