In an action, i've got a script that connects to a https end point and pull some data to populate into an input field.
so i'm trying to read configuration elements and get this error
Error in (Dynamic Script Module name : GetListOfGroups#1) TypeError: Cannot find function getAttributeWithKey in object function ConfigurationElement() {
[native code, arity=0]
Here's my code in the action
System.log("starting")
var username = ConfigurationElement.getAttributeWithKey("wfconf.username").value
var password = ConfigurationElement.getAttributeWithKey("wfconf.password").value
var vendorkey = ConfigurationElement.getAttributeWithKey("wfconf.vendorkey").value
Trying to figure out where i could be going wrong here.
ConfigurationElement is a scripting type. You cannot invoke the method getAttributeWithKey() directly on the type; instead, you should obtain an instance of object of this type (eg. by passing it as an input parameter to your scripting action), and then invoke getAttributeWithKey() on this instance.
See for example the scripting action com.vmware.library.configurations.getObjectFromConfigurationElementWithKey() that comes out of the box with vRO.
ConfigurationElement is a scripting type. You cannot invoke the method getAttributeWithKey() directly on the type; instead, you should obtain an instance of object of this type (eg. by passing it as an input parameter to your scripting action), and then invoke getAttributeWithKey() on this instance.
See for example the scripting action com.vmware.library.configurations.getObjectFromConfigurationElementWithKey() that comes out of the box with vRO.
Thank you.
I figured out another way. Those values were already part of my attributes for the workflow and the action was used to populate a drop down so I just used those attributes as variables to my action and that worked out just fine
thank you again.
This actually proved to be quite useful. thank you iiliev
iiliev
How does getAttributeWithKey() work with securestrings.
i think i cannot do
var password = config.getAttributeWithKey("password").value;
where config is the parameter in the action.
am i doing something wrong?
thanks!
That should work. Are you getting an error? I believe .value will be a string though not a secure string.
you're right. initially, it returned an exception with a value of null.
i can't think of what i did to fix it but it's working as expected now. Thanks again for the tip.