VMware Cloud Community
TomHEMC
Contributor
Contributor

How can I associate hidden values with the visible items in a predefined list of Elements?

Hi All,

I'm relatively new to vCO but I've got a good handle on setting up my Presentation to provide a picklist via a Property set to a Predefined list of elements and calling an Action that returns a string array.

Now I need to have the user pick an item from the list but I need to actually *use* a corresponding id for the item chosen. So for example, red:1, blue:2, green:3, etc. I need to show the red, blue, green but I need the corresponding values 1,2,3 to use in the rest of the workflow. The Id's in my case are big hairy URI's that I don't want to show. How do I go about this? It seems like I need to return an arrya of objects with these properties from my action but I'm not sure what to do with it from there and I haven't seen any examples of such a thing.

Thanks for any help,

Tom

Tags (2)
0 Kudos
8 Replies
cdecanini_
VMware Employee
VMware Employee

You can create attribute of type array of composite type with id, value as columns and fill it with your values.

Then you can use an action for the presentation that return the list of values from this attribute.

In the workflow you can have an action getting the ID for a given value of the composite type.

A composite type can be used the same way as the Properties object except it allows to be edited.

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
cdecanini_
VMware Employee
VMware Employee

And a simpler solution is just to use 2 arrays of strings. One for IDs and one for values.

Once a value is set you can do var nb = values.indexOf(value);

var id = values[nb];

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
TomHEMC
Contributor
Contributor

Thanks, I actually thought of creating a composite type but got stuck on how to actually use it in the presentation/workflow.

First, I know I can create this type as an attribute of the Workflow but can I create a more global type so that I can use it in a corresponding Action? I want to return the same type from the action so how does it know about it?

Next, assuming I create this composite type as an attribute of my workflow, I can't really fill it until I get some of the input parameters so I can pass those to the Action to get the list of names and values - hope that makes sense. Does that mean I should make it an Input so that I can bind an action to it and use other inputs?

To help understand my goals, I'm building a "Restore a Backup" workflow. My input is the Client name, which I present in a picklist bound to an action which returns those names. When the client is selected, I want to show the Timestamps for all the backups I have for that client. To do the restore though, I need the backupId that matches the timestamp. My backup application API returns a JSON object that has all the backups as objects where each object has properties for the timestamp and id. I can solve this with two calls to the backup application and just match the selected timestamp with the timestamp on the second call but I was hoping to not have to make that call twice.

I appreciate your help on this.

0 Kudos
cdecanini_
VMware Employee
VMware Employee

If the composite type needs to be set on the fly it may make it more complex. Also there is no global composite type. It needs to be redefined each time which is not very convenient.

You can use 2 inputs of type array, one being displayed for the end user and one hidden and use the second method I provided to find the ID from the value. You could even have the 2nd input be set automatically using a data binding linked to the action returning the element of the array.

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
TomHEMC
Contributor
Contributor

Wouldn't using two string arrays require making two calls to fill them (one each)?

0 Kudos
cdecanini_
VMware Employee
VMware Employee

Right. If this calls are resource expensive and cause performance issues you can make a single call, save the result in a config element or using the putInCache(key value) method in the action returning the list of values then have a script in the workflow getting from cache.

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
qc4vmware
Virtuoso
Virtuoso

Can you tell us a little more about the putInCache you just mentioned?

0 Kudos
cdecanini_
VMware Employee
VMware Employee

putIncache, getFromCache are methods that are part of the Dynamic Types plug-in.

I have requested these features to have a solution for caching the plug-in objects avoiding doing many http get requests (or similar) when unnecessary.

Besides the use for plug-ins it is a very convenient way to cache objects for the workflow presentation.

The drawback is that being in a memory cache only and not shared between cluster instances it should not be used as global variables.

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