chrisxhartmann
Contributor
Contributor

Actions in presentation layer

Jump to solution

I have several workflows that have a number of drop down menu selections on the presentation layer that are populated based on selections for other menus (eg. Selecting a customer from one menu will populate the next with all the VMs in that customers folder). However, I am finding that I am having to repeat lots of script in the actions attached to these menu items or in the workflow itself.

For example, when selecting a VM from the menu mentioned previously the action I have attached to it will return an array of all VM objects and then push the name property from each into another array and then return this as an array of strings to create the drop down menu. When the workflow starts I then have to convert the string back into a VM object in order to work with the VM. Given that I already created the array of VM objects, is there any way to reuse it when created in the presentation layer? Can I pass that array of objects to another parameter on the presentation layer for manipulation by another action?

Thanks,

Chris.

0 Kudos
1 Solution

Accepted Solutions
iiliev
VMware Employee
VMware Employee

Hi Chris,

You cannot do it with a single action. You need to have one action for the hidden input field, returning the shared value (in this case, the array of virtual machines in a given folder), and one action for each other input field that will show data computable using the shared value which will be passed as an input parameter to the action (in your case, if you want to have a field displaying a dropdown with the virtual machine names, you can have an action returning array of string, and taking as an input array of virtual machines - the hidden input parameter).

View solution in original post

0 Kudos
4 Replies
iiliev
VMware Employee
VMware Employee

One option would be to have a hidden input parameter (of type Array/VC:VirtualMachine in your case), populate it with the list of VMs in customer's folder, and pass its value (using #fieldname syntax) as an input parameter to other actions. Each action that want to consume this value should be extended by adding one more input parameter to it of the same type as the hidden input.

0 Kudos
chrisxhartmann
Contributor
Contributor

Hi Ilian,

Thanks for the reply. Excuse my lack of understanding, but where I return Array/string from an action, how do I also return Array/VC:VirtualMachine from the same action? If I understand correctly, your example only deals with passing the array to the next field on the presentation, but what I really need to know how I create both from a single action to begin with or if this is even possible.

Thanks,

Chris.

0 Kudos
iiliev
VMware Employee
VMware Employee

Hi Chris,

You cannot do it with a single action. You need to have one action for the hidden input field, returning the shared value (in this case, the array of virtual machines in a given folder), and one action for each other input field that will show data computable using the shared value which will be passed as an input parameter to the action (in your case, if you want to have a field displaying a dropdown with the virtual machine names, you can have an action returning array of string, and taking as an input array of virtual machines - the hidden input parameter).

View solution in original post

0 Kudos
chrisxhartmann
Contributor
Contributor

Hi Ilian,

That's perfect thanks. I was stuck with how to hide the input parameter as I couldn't see what I should enter into the attribute to keep it hidden and then realised just set the attribute and leave it blank :smileylaugh:

Thanks for your help on this.

0 Kudos