VMware Cloud Community
JuanHerreraadsg
Contributor
Contributor
Jump to solution

Adding strings/populating an array of type array/string

Hello,

I am a newbie here working with vCO.  I am working on VM deployment workflow that starts with gathering some General information (server contact, email, etc) followed by specific VM Information (i.e. web/application/db as well as environment).  The latter (VM information) is input by prompting the user for the type of system they wish to deploy iterating each time based on the number of VMs requested (with a counter - counter = numVMs).  I am attempting to pass these information to an attribute of type "array/string" (the input of the type of server is "string") so i can later call the "Clone VM" for each VM input in the array.  The rest of the information is passed in the same manner to the array attributes (environment, operating system, etc).

So far i have tried many variations to populate the array but it doesnt work. What this means is that every time i try to update the attribute that holds the VM type array with an array member (array[i] = whateverstring;) I get a "object error".  For what i understand it has to do with the string to object type but i'm not 100%.   I also tried using the "VcArrayUpdateOperation" object but i'm not sure how it works (i guess there is a specific way of doing this but no concrete examples).  Can someone please shed some light on this?

Thanks in advance!

0 Kudos
1 Solution

Accepted Solutions
cdecanini_
VMware Employee
VMware Employee
Jump to solution

You need to:

  • Initialize your Array (by clicking on the attribute "not set" and "accept")
  • Make sure your array is in the inputs and outputs of your scriptable box .
If my answer resolved or helped you, please mark it as Correct or Helpful to award points. Thank you! Visit http://www.vcoteam.info & http://blogs.vmware.com/orchestrator for vCenter Orchestrator tips and tutorials - @vCOTeam on Twitter

View solution in original post

0 Kudos
4 Replies
tschoergez
Leadership
Leadership
Jump to solution

Hi,

cam you give us your code examples, that makes it easier to troubleshoot...

In general:

Try to initialize the array with

var myarray = new Array();

Then you can add element to the array with

myarray.push("some string");

Check www.eloquentjavascript.net<http://www.eloquentjavascript.net>; for a good intruduction to JavaScript.

Also check www.vmwarelearning.com/orchestrator<http://www.vmwarelearning.com/orchestrator>; ,I think there is a demo video how to work with arrays in vco available on there.

Cheers

Joerg

Gesendet von meinem LG Mobile

0 Kudos
JuanHerreraadsg
Contributor
Contributor
Jump to solution

Hello,

Thanks for your reply.  This is what I have tried so far (after input from the user interaction object):

Global attributes:

a_vmType -  array/string  (defines whether it is a Web/Application/Database to set appropriate resources)

a_tempVMType - string  //used to bind the input from user interaction

Code1:

var i = counter;  //where counter = numVMs requested

var i = counter;

i = i--;  //to populate the members of the array starting with "0"

a_vmType[i] = a_tempVMType;  //populate the array members

Code1 error:  TypeError: Cannot set property "0.0" of null to "Web" (Workflow:TEST_NewVMs / Scriptable task (item2)#4)

--------------------------------------------------------------

Code2:

a_vmType.push(a_tempVMType);

Code2 error: TypeError: Cannot call method "push" of null (Workflow:TEST_NewVMs / Scriptable task (item2)#7)

0 Kudos
cdecanini_
VMware Employee
VMware Employee
Jump to solution

You need to:

  • Initialize your Array (by clicking on the attribute "not set" and "accept")
  • Make sure your array is in the inputs and outputs of your scriptable box .
If my answer resolved or helped you, please mark it as Correct or Helpful to award points. Thank you! Visit http://www.vcoteam.info & http://blogs.vmware.com/orchestrator for vCenter Orchestrator tips and tutorials - @vCOTeam on Twitter
0 Kudos
JuanHerreraadsg
Contributor
Contributor
Jump to solution

Thanks cdecanini, that did it!  Once I initialized the array....booom, started flowing.  That's awesome...

0 Kudos