Hello,
I need to concatenate informations in an object to be able to link those objects
example I have a list of datastores I need to remove. I want to link them to the storagepod, the host and the canonical name
I want to create an object in the form
datastores (table)
name string
storagepod storagepodobject
host hostobject
CN string
How can I create those type of object in javascript or is there a solution in the vcenter API ?
In Select DS scriptable task, there is an error at the end of for each loop, where you try to add obj element to objetTraitement array.
Instead of:
objetTraitement += obj;
it should be
objetTraitement.push(obj);
The object can be just a collection of propertyname:propertyvalue elements, where the propertyname is a string representing the corresponding object field name, and propertyvalue is the corresponding object value of the filed. To construct it is easy:
var myname = "some name";
var myspod = ...; // storage pod value (of VC:StoragePod type)
var myhost = ...; // host value (of VC:HostSystem type)
var mycn = "some cn";
var obj = { "name" : myname, "storagepod" : myspod, "host" : myhost, "cn" : mycn }
You can use this object instance in the same way you use the other objects. Like
var arr = []; // create an empty array
var obj = { "name" : myname, "storagepod" : myspod, "host" : myhost, "cn" : mycn }
arr.push(obj); // adds object to the array
var pod = obj.storagepod; // retrieve the value of the storage pod field
it works on one module but If I want to use the object Array in multiple Scripting modules
because I remove an Array of Datastores so for each datastore I start a script module that need to push the obj object to the arr Array
tried to set the array in the first scripting module of the workflow but I had an error arr not an array
so I tried to set the arr Array in the module itself but the array is reinitialized at each datastore
If possible, could you export your test workflows/actions and and attach them to this thread so I can take a look at the exact code?
here is the test worlflow
you can delete the action used to filter the input datastores
the array I want to populate for each datastore is "objetTraitement"
Hmm, I don't see anything attached.
In Select DS scriptable task, there is an error at the end of for each loop, where you try to add obj element to objetTraitement array.
Instead of:
objetTraitement += obj;
it should be
objetTraitement.push(obj);
thanks ilian It works !
a last question How can we understand those types of error?
orchestrator sometime give the line number where the error is but in this case it speaks about Item?
how can I know which item it is ?
Workflow:supprime Datastore / Select DS (item7) : ch.dunes.model.type.ConvertorException: Not an Array
Go to Schema tab in the workflow designer, and hover with the mouse over workflow items; a tooltip window will be shown containing item's label and item's number.
And usually, in case of error, the corresponding workflow item where the error is thrown is highlighted in red color.