VMware Cloud Community
MC2016
Enthusiast
Enthusiast
Jump to solution

Passing workflow attribute to sub workflow?

Hello All,

Hoping someone can shed light on what exactly I have wrong in my workflow. I have a parent workflow with a script able task output of string attribute called "cluster". This output fine as i have a system.log setup on script able task after the "cluster" attribute is defined.

My issue is when i try and pass the "cluster" attribute into a sub workflow it doesn't show in system.log output.  When i map sub workflow input as input in parent workflow, everything works fine.

Any ideas?

1 Solution

Accepted Solutions
iiliev
VMware Employee
VMware Employee
Jump to solution

In the scripting code of getAllClustersInDC, on line 24 you have the following assignment:

cluster = clusterfound;

Here, cluster is of type string, but clusterfound is of type ClusterComputeResource.

Could you try to change this line to something like:

cluster = clusterfound.name;

View solution in original post

8 Replies
sandy_1234
Enthusiast
Enthusiast
Jump to solution

Can we check the type of the variable inside the workflow by using the java-script function below.

System.log(typeof(cluster));

I had faced a similar problem after parsing xml tag and retrieved a value when i try to pass it as an attribute to another workflow, it was showing 'null value'. Had to use variable.toString() function to convert it to desired type. Ensure the type matches.

Thanks

Sandeep

Reply
0 Kudos
iiliev
VMware Employee
VMware Employee
Jump to solution

Hi,

How and where the value of the 'cluster' attribute is set. For example, is its value set directly in the attributes table, or its value is set dynamically in some of the scriptable tasks? If the latter, then you must ensure that the corresponding scriptable task has the 'cluster' attribute set as OUT parameter of the task; otherwise, the attribute value will not be propagated.

Reply
0 Kudos
MC2016
Enthusiast
Enthusiast
Jump to solution

This was output when i put that into a scriptable task

[2019-02-20 15:13:19.804] [I] function

iilievIlian Iliev

The variable cluster is an attribute but is defined in the scriptable task "getAllClustersInDC". I validate it function by having a scriptable task "Test if cluster variable " after it in the workflow that has System.log("Cluster name is:" + cluster); It outputs cluster name correctly. Next part is the sub workflow  "Testinput" which has cluster input mapped to cluster attribute. Inside sub workflow i have scriptable task with System.log(Cluster name input:" + cluster;

inside workflow Testinput i have a scriptable task with System.log("Cluster name:" + cluster); Always outputs "Cluster name" but cluster is blank when defining it in parent workflow. Only work when i have cluster linked to input instead of attribute.

I've attached two workflows I'm using if you wish to look at what I'm using.

Reply
0 Kudos
sandy_1234
Enthusiast
Enthusiast
Jump to solution

Would bit possible to export the WF and upload here ?

Thanks

Sandeep

Reply
0 Kudos
MC2016
Enthusiast
Enthusiast
Jump to solution

see attached workflows. Wouldn't let me add them to above post

Reply
0 Kudos
iiliev
VMware Employee
VMware Employee
Jump to solution

In the scripting code of getAllClustersInDC, on line 24 you have the following assignment:

cluster = clusterfound;

Here, cluster is of type string, but clusterfound is of type ClusterComputeResource.

Could you try to change this line to something like:

cluster = clusterfound.name;

MC2016
Enthusiast
Enthusiast
Jump to solution

That worked for me.

So i need to change cluster to VC:clustercomputeresource and i'll be able to access child items of cluster in the sub workflow, correct?

Reply
0 Kudos
iiliev
VMware Employee
VMware Employee
Jump to solution

That's correct.

Reply
0 Kudos