VMware Cloud Community
spride
Enthusiast
Enthusiast
Jump to solution

Dynamically-created form values

This may not be possible at all, but thought I'd ask.

I'm creating a workflow that will allow the user to change the memory and/or CPU count for a VM.  The VM can reside on one of two vCenters under predefined folders.  The first thing the user does is selects which vCenter the VM resides.  Based on this selection, the form calls an action that retrieves all of the VMs on the vCenter from the predefined folder on that vCenter.  It then populates a drop-down on the form with a list of the VMs.  Next thing the user will do is select the new memory and/or CPU count for the VM.  What I want to do is make the default values for the memory and CPU count dynamic based on the VM that is currently selected in the drop-down list.  However, this value comes from the action call earlier - IOW, the values are dynamically updated themselves.  Is there a way this can be achieved?

0 Kudos
1 Solution

Accepted Solutions
iiliev
VMware Employee
VMware Employee
Jump to solution

This error means your action getVmMemory() expects an input parameter of type number, but there are no other parameters of type number to bind to.

Why does this action expect a number input? Shouldn't it accept a string input (vmName input parameter, and possibly also the location input parameter if needed), and return number value?

View solution in original post

0 Kudos
8 Replies
iiliev
VMware Employee
VMware Employee
Jump to solution

Could you attach your workflow to take a look?

From the description, it sounds like you are using 'Default value' presentation property to compute for memory and CPU count fields; is that correct? 'Default value' indeed is evaluated early and only once. You may try another presentation property - 'Data Binding', which is evaluate every time the field(s) it depends on change.

0 Kudos
spride
Enthusiast
Enthusiast
Jump to solution

Thanks.  I tried using Data Binding, but one of the parameters I need is the current selection from the VM drop-down (which itself is dynamically created if the location is changed by the user).  When I choose the appropriate action for the data binding, I can't add that parameter as it doesn't show in the list:

Screen Shot 2016-02-24 at 8.47.54 PM.png

In a way this makes sense ... Because both the action for the VM drop-down and the action for the memory would fire at the same time (I would think).  Although, just like when the drop-down list values change when the location is changed, it would be nice if the memory value changes when the current selection in the drop-down list changes.

Here is what the "location" looks like:

Screen Shot 2016-02-24 at 8.47.29 PM.png

And here is what the "vmName" looks like:

Screen Shot 2016-02-24 at 8.47.32 PM.png

The "getAllVMsByRegionInFolder" returns a list of all VMs in the predefined folder for the region specified by "#location".

0 Kudos
iiliev
VMware Employee
VMware Employee
Jump to solution

This error means your action getVmMemory() expects an input parameter of type number, but there are no other parameters of type number to bind to.

Why does this action expect a number input? Shouldn't it accept a string input (vmName input parameter, and possibly also the location input parameter if needed), and return number value?

0 Kudos
spride
Enthusiast
Enthusiast
Jump to solution

That;s strange as the input parameter is a string.  The output value is a number.

0 Kudos
iiliev
VMware Employee
VMware Employee
Jump to solution

Hmm, does it work if you manually provide the bound parameter? Just click on the yellowish field and change

GetAction("com.snapfish.spride.test","getVmMemory").call( "" )

with

GetAction("com.snapfish.spride.test","getVmMemory").call( #vmName )
0 Kudos
spride
Enthusiast
Enthusiast
Jump to solution

Yea, I tried that, too.  When I opened the form it would just spin and spin and then finally gave me a generic error.  For now, I went to Plan "B".  I may come back to this later as it seems like something that would be routine, but maybe not.  Thanks.

0 Kudos
spride
Enthusiast
Enthusiast
Jump to solution

So it turns out I needed to debug my issue more and I would have found the problem.  It turns out the original value for the second call is fired before it has time to gather the info from the first call (I should have known that).  So the list does not have a single value in it yet.  Therefore, when the second call runs the action, it has null data, which I'm trying to use.  Embarassed since it was seemingly a novice mistake not checking for a null value in the second action.  Thanks for your help.  I figure I owe you some points for helping so flagged your response as correct.

0 Kudos
DCJoe
Contributor
Contributor
Jump to solution

We drastically reduced overhead in programming calls by making Business Units = vCenters, effectively releaving us of having to filter, The Business Unit Filters the machines, folders, and Resource Pools automatically. Reading the Business Group Properties and using the Business Group as a filter might help in the long run.
0 Kudos