VMware Cloud Community
ericr999
Enthusiast
Enthusiast
Jump to solution

Inputs values, properties in presentation

Hello,

Anyone has ever tried to do a workflow with input values that the same value could be used over 30 workflows for different purpose, but still I'd like to control the input values.

So far we weren't controlling input values, but I'm trying to do that now, and I was thinking to use a Configuration Element to store my possible value for that input parameter. Is that possible ?

So far I haven't found out how to do that.

Thanks!

0 Kudos
1 Solution

Accepted Solutions
iiliev
VMware Employee
VMware Employee
Jump to solution

Yes, this code can return values for config element attributes of any type, including array/string.

When the action returns an array object, you can bind the result in presentation to an input parameter which is also array (in this case, the whole returned array will be visible in the input field). Or you can bind a single element of the returned array to input parameter that is singular/not an array, using expression that looks something like (elementindex is a number from 0 to size-of-the-array - 1)

   GetAction("com.vmware.util","getConfigAttributeValue").call( "test" , "config" , "att0" )[elementindex]

View solution in original post

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

Hi,

If I understand correctly, you want to store some value in configuration element attribute, and use this attribute as a default value for an input parameter of over 30 workflows?

This can be done easily. The first step is to create a vRO scripting action with signature something like

Any getConfigAttributeValue(string cfgPath, string cfgName, string cfgAttr)

and scripting code

var category = Server.getConfigurationElementCategoryWithPath(cfgPath);

var cfgElements = category.configurationElements.filter(function(elem) {

  return elem.name == cfgName;

});

var attr = cfgElements[0].getAttributeWithKey(cfgAttr);

return (attr == null) ? null : attr.value;

What this code does is (1) find config category by its hierarchy path, (2) find a configuration element inside this category with a given name, and (3) retrieve the value of an attribute of this config element with a given name.

The second step is to go to presentation of your workflow, select the input parameter whose default value you want to pre-populate from the configuration element attribute, add 'Default value' property, and for its value add action call looking similar to the following

GetAction("com.vmware.util","getConfigAttributeValue").call( "test" , "config" , "att0" )

where 'com.vmware.util' is the name of the action module where you created the action getConfigAttributeValue()

'test' is the path to your configuration element

'config' is the name of the configuration element

'att0' is the name of config element attribute holding the value you want to pre-populate

In the above, you should replace com.vmware.util, test, config and att0 with actual values/names from your setup.

If this is not exactly the case you want to cover, please provide some more details/examples.

0 Kudos
ericr999
Enthusiast
Enthusiast
Jump to solution

Hi Ilian!

Always there to answer all my questions!! Smiley Wink

With the code above, will I be able to pull values from a Config Elements that the type is Array/string ?

And input that into the presentation ?

That would be my ultimate goal.

The point is to have workflows that can pull values like site location, so from my 30 workflows, the sites should always be 4 values, but I want to limit the possibilities.

So far I was using string as input values, but to many things can go wrong, and it would be better if I can control the values via a Config Element.

Thanks for your help again!

0 Kudos
iiliev
VMware Employee
VMware Employee
Jump to solution

Yes, this code can return values for config element attributes of any type, including array/string.

When the action returns an array object, you can bind the result in presentation to an input parameter which is also array (in this case, the whole returned array will be visible in the input field). Or you can bind a single element of the returned array to input parameter that is singular/not an array, using expression that looks something like (elementindex is a number from 0 to size-of-the-array - 1)

   GetAction("com.vmware.util","getConfigAttributeValue").call( "test" , "config" , "att0" )[elementindex]

0 Kudos