vRA 7.4 Custom Forms – Value Picker

Hey All,

In this is the first of a series of quick videos/posts about how one could use the elements available in vRealize Automation Custom Forms.
This is by no way the only way and would be great to get peoples feed back and experiences on these.

Elements available to use are:

  • Value Picker
  • Data Grid
  • Multi Select
  • Drop Down
  • Text Field
  • Text Area
  • Text
  • Password
  • Decimal
  • Integer
  • Image
  • Dropdown
  • Checkbox
  • Radio Group
  • Date Time

 
Today we are looking at Value picker, Below is a video that I prepared earlier.

Value Picker

There is number of ways you can use value picker. I personally do not think it’s fully featured yet as there are some elements to it I believe should work better. I will not be going into every setting as there are many like visibility, read only custom help etc which are shared across all. I will have a separate post on general use.

The idea of value picker is that you can display, search and select object types different from the primitive types like sting, integer, bool etc. When you select the value picker on the the form you will notice the reference type field. This is where you can type a vRealize Orchestrator (vRO) object type. As you can see form the below image I have chosen AD:User.

This means if we choose to have an action for external values it will need to return an array of AD:User but what this also does well is it will automatically grab all your AD users from the vRO AD plugin to select for a default user.

This is where I think it falls short, because it can see and search all AD:User objects returning their name, wouldnt it be good if thats all we needed to do. If we were to save this and test the form I would have assumed it could search just like it could for selecting a default value. but unfortunatly thats not the case.

So now onto giving it some values to work with. I like to use external values, so I create one to return all my AD users. The value picker will only look for actions that have an output matching the reference type that was selected.

action code
var adHost = System.getModule("virtualiseme.activeDirectory").getAdHost(domain);
System.debug(adHost);
var users = ActiveDirectory.search("User","",adHost);
return users;

Now if we are to test out the form again, we notice all of the ad users are displayed in the value picker. There is a small downside, the search functionality does not appear to work using it this way, and it is not as clean as how you can select a default value which tells it shouldn’t need an external value to work should just work like it does when selecting a default value but doesnt appear to be the case atm.

If you now provision a machine with a selected value it will pass the vRO reference for that object to the machine as a custom property and can be used in any EBS workflow or software component, This is fine and there are many ways to use this. But using a string and a standard drop down would be just as efficient.

I did try and be smart and have another field that would take the input of value picker, which it picks up that value picker field in this instance is AD:User and I could select that as an input of another field, the form would error saying it could not make the conversion of the object. Unfortunately the forms can not pass of handle complex objects just yet.

If you have any further input or advice for everyone please post below.

Cheers

****UPDATE*****

My new action of:
var filter = System.getContext().getParameter("__filter");
var adHost = System.getModule("virtualiseme.activeDirectory").getAdHost(domain);
System.debug(adHost);
var users = ActiveDirectory.search("User","",adHost);
if (users == null) {
return [];
}
var filteredResult = [];
for each(item in users) {
if (item.Name.indexOf(filter) > -1) {
filteredResult.push(item);
}
}
return filteredResult;

Thanks to Lieselot’s comment below I thought I would write this up, something I came across a little while ago but haven’t had the time to post it.
From the above snip-it above you might be thinking where dose “__filter” come from. when a custom form kicks of an action it will pass some values, very similar to working with XaaS in vRA it passes __ values that can be used in a workflow.
Not all custom form widgets pass parameters but Value picker passes __filter this is how you can return the array this is filtered on that value ( I still think it should do this automatically as it does it for default value but that is another fight 🙂

you can filter on any value an object has so user has name, or account name or category I chose name. *Note* it is case sensitive by default so you would have to account for that.

If you want to check on the values passed from a custom form widget use this in your external value action:
var params = System.getContext().parameterNames();
System.log(params);
for each (var p in params){
System.log(p);
}

and look at the vRO server.log and see them outputed
Cheers

5 Replies to “vRA 7.4 Custom Forms – Value Picker”

  1. Hi,

    I opened a case with VMware because I had the same problem. The search does not work in the form if you use an action as external source. This is an example for VC:VirtualMachine

    var filter = System.getContext().getParameter(“__filter”);
    var result = Server.findAllForType(VC:VirtualMachine);
    if (result == null) {
    return result;
    }
    var filteredResult = [];
    for each(item in result) {
    if (item.value.indexOf(filter) > -1 || item.id.indexOf(filter) > -1) {
    filteredResult.push(item);
    }
    }
    return filteredResult;

    I changed this to be able to look for the name and not the id
    (item.value.indexOf(filter) > -1 || item.name.indexOf(filter) > -1)

    Hope this helps

    • Hey Lieselot,

      Thanks heaps for posting that, I recently discovered the same thing. custom form widgets will send through paramerters and value picker happens to be __filter.

      you can print these out in the log using something like:
      var params = System.getContext().parametersNames();
      for each (item in params){
      System.log(item);
      }

      Then you can see what to work with.

  2. i am using your action code
    in my case its keep searching and i am unable to type initials of username

    will you please share action code for GetHost for same.

    • Hey Jeet,

      this for get ad host?
      mine is more complext than it needs to be. but you can use something simple like:

      var result = Server.findAllForType("AD:Adhost");
      for each(host in result){
      if(host.name == domain){
      return host;
      }
      }

      I have all my ad host endpoints name as the domain name eg virtualiseme.com.au make it easy when needing to return or search.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

Anti SPAM BOT Question * Time limit is exhausted. Please reload CAPTCHA.