VMware Cloud Community
javier_dp
Contributor
Contributor
Jump to solution

Input values (drop down) based on other input selection

Hi

First of all accept my apologies if this is a very basic question. I am setting up a work flow to deploy virtual machines. Depending on the environment, i want to have some default values filled with different values.

The presentation has a first step to choose the destination environment, which can be development, production, etc

I am trying to fill the host / datastore / resource pool  values in the presentation based on the environment selection.

I am having a hard time to find examples or documentation on how to do this. I have seen that there are ways to show/hide parameter inputs with #variablename < value for instance, but i can't tell how to apply this to a default value

The idea would be

VC:HostSystem:

Select value as tree

Predefined list of elements: If Env = Dev, get hosts from certain datacenter, If env = prod, get hosts from certain datacenter.

Thanks

0 Kudos
1 Solution

Accepted Solutions
ChristianWehner
VMware Employee
VMware Employee
Jump to solution

Hi Javier,

now you have to build four actions where you define a string input parameter. On the first one, you decide which hosts you want to show for dev and which for prod, and those you have to return. Something like this:

switch (true)

{

     case inputEnvironment == "dev":

        myHostNamesArray.push( "devHost1" );

        myHostNamesArray.push( "devHost2" );

        myHostNamesArray.push( "devHost3" );

        break;

     case inputEnvironment == "prod":

        myHostNamesArray.push( "prodHost1" );

        myHostNamesArray.push( "prodHost2" );

        myHostNamesArray.push( "prodHost3" );

        break;

}

return myHostNamesArray;

Or you build any other logic to get the hosts you want as input returned. Maybe you could return the VcHostSystem Objects instead of the Names of the Hosts which will be easier to handle in your following workflows Smiley Wink

Now build the same for datastores, resource pools and folders.

Select the action on presentation as shown in the picture in one of the posts before and choose the result of your first question as input.

Regards,

Chris

View solution in original post

0 Kudos
8 Replies
javier_dp
Contributor
Contributor
Jump to solution

Other example is:

I want to use a Template A if env is Dev, but Template B should be used if the user chose Prod as the environment.

0 Kudos
ChristianWehner
VMware Employee
VMware Employee
Jump to solution

Hi,

you can use an action the retrieve an array of elements you wish to show. Also you can use your environment selection as input for this action to show only specific elements. It is the button with the blue symbol on the right end of the presentation properties tab if you added a propertie.

presentation.png

Regards,

Chris

0 Kudos
cdecanini_
VMware Employee
VMware Employee
Jump to solution

You can do this by:

Creating actions returning an object or array of objects based on a an input.

Use the presentation properties default value or predefined list of elements, or root object.

If your input is a list of string vlue instead of an object, just create an attribute with an array of string, use predefined list of elements and use an action to return the right object based on string input.

Christophe.

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
cdecanini_
VMware Employee
VMware Employee
Jump to solution

Another Chris was faster :smileylaugh:

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
ChristianWehner
VMware Employee
VMware Employee
Jump to solution

:smileysilly:

0 Kudos
javier_dp
Contributor
Contributor
Jump to solution

Hi

I already have placed the drop down list of environments. The values are fetched from an array defined in the General Tab. I am now able to select either Dev or Prod environment from that drop down menu.

I am stuck in the next step:

- If the user selects Dev environment:

Fill the rest of the inputs with:

* dev host [fetched from a variable array(host1, host2, host3)]

* dev datastores [fetched from a variable array(ds1, ds2, ds3)]

* dev resource pools [fetched from a variable array(res1, res2, res3)]

* dev folders

- If the user selects Prod environment:

Fill the rest of the inputs with:

* prod host

* prod datastores

* prod resource pools

* prod folders

Although I would like to dynamically fill this with values fetched from vCenter, I can live with getting this values from predefined variables.

This is my first workflow, so i'm pretty sure that what i ask is very obvious, but this is all new for me. Thanks for your support

Message was edited by: javier_dp

0 Kudos
ChristianWehner
VMware Employee
VMware Employee
Jump to solution

Hi Javier,

now you have to build four actions where you define a string input parameter. On the first one, you decide which hosts you want to show for dev and which for prod, and those you have to return. Something like this:

switch (true)

{

     case inputEnvironment == "dev":

        myHostNamesArray.push( "devHost1" );

        myHostNamesArray.push( "devHost2" );

        myHostNamesArray.push( "devHost3" );

        break;

     case inputEnvironment == "prod":

        myHostNamesArray.push( "prodHost1" );

        myHostNamesArray.push( "prodHost2" );

        myHostNamesArray.push( "prodHost3" );

        break;

}

return myHostNamesArray;

Or you build any other logic to get the hosts you want as input returned. Maybe you could return the VcHostSystem Objects instead of the Names of the Hosts which will be easier to handle in your following workflows Smiley Wink

Now build the same for datastores, resource pools and folders.

Select the action on presentation as shown in the picture in one of the posts before and choose the result of your first question as input.

Regards,

Chris

0 Kudos
rubberduck70
Contributor
Contributor
Jump to solution

Hi guys

I know this is an old post but came across it to perhaps assist with the same requirement I have on my end. As mentioned, we would also like to (based on input), select either a Dev/Test workflow with it's resources and the same for PROD. I tried to follow the below points on how to create the action elements and input variables...I am stuck. Nothing seems to be populating. Would it be possible to send a screenshot or detailed description on how I can achieve this? Perhaps with the javascript variables I need to pass?

thank you

0 Kudos