VMware Cloud Community
magander3
Enthusiast
Enthusiast

Create vRO drop-down from configuration element to be used in vRA XaaS

Hi,

I have a vRA XaaS blueprint where the end user is suppose to select placement target in the request workflow.  Available placement targets are stored in a vRO configuration element, places, with four attributes according to:

Name: Place1 Value: 1111
Name: Place2 Value: 2222
Name: Place3 Value: 3333
Name: Place4 Value: 4444

Right now i have an action which reads the attributes and creates an array according to:
net.push(attribute.name + " " + attribute.value);
This gives [Place1 1111,Place2 2222,Place3 3333,Place4 4444]

In the vRO WF i have set a Property "Predefined list of elements" too GetAction("com.mydomain","getPlacements").call( ) but i'm just getting the following error.

"OGNL error: Method"call" failed for object , Action 'getPlacements' in module "com.mydomain' failed : TypeError: Cannot read property "attributes" from null (unnamed script#1)"

i'm using vRO 7.6

Any help would be much appreciated.

Thanks

Reply
0 Kudos
2 Replies
iiliev
VMware Employee
VMware Employee

Hi,

The error says than on second line in your scripting code you have expression that contains something like somevariable.attributes, and that its left side (somevariable) is null.

In your case, probably somevariable is your configuration element, from which you are trying to read attributes. You haven't provided the full source code, so I cannot say why it is null. Perhaps you are not passing it or not searching for it correctly.

Reply
0 Kudos
DWBrush
Contributor
Contributor

Hello,

The issue is that in an action element you must define the Configuration Element you are using with an input parameter.

In your action element, add a parameter of type ConfigurationElement called something like 'inputConfigElement'. The name needs to match the variable you are using for your loop through

the config element in your script. I assume your script looks something like this:

var atts = inputConfigElement.attributes

var retArray = [];

for each(var a in atts){

     retArray.push(a.name + " " + a.value)

     }

return retArray

In your workflow, define an attribute of type ConfigurationElement with the configuration element you want to use. For example, name the attribute 'attConfigElement', and assign it the value 'placementConfigElement' (or whatever your config element is called).

Then, in the presentation tab of your workflow, the call you are using for the action element should look something like this:

GetAction("com.mydomain","getPlacements").call( #attConfigElement )

Cheers,

-D