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
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.
Thanks for the info!
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.
In 7.5 vRA version, inside the Value Picker, you have to configure only the Reference Type (AD:User), not value options (contant without values), and then when you launch the custom form you can search right away in the default AD configured in vRO.
Regards
Hey Kiko,
That’s Awesome I have not had a chance to re-visit 7.5 and see what had been improved. Just tested and, exactly how I wanted it to work originally.
Cheers
Hey Lieselot,
I am new to vRA and your videos has really helped me get going. I need some help on how to create a blueprint to to change computer UO in Active directory
Thanks again
Hey Joseph,
vRA has an ootb feature called active directory policies which will place the computer object into an AD OU based on Business Group, Out side that the most common way to do this is to use EBS to run a workflow at the pre building event to create the AD account in a specif OU based on form entries. Or to run a post building workflow to move the machine to the correct OU.
Cheers
Thanks Scott for the response,
How do I create a a post building workflow to move the machine to the correct OU.
That’s my dilemma as I am new to vRA
If possible can you share getModule(“virtualiseme.activeDirectory”) with us. I am not able to execute from my VRA catalog. Script which I am using
This is working on VRO but in VRA it is failing
var ou= ActiveDirectory.search(“OrganizationalUnit”,””,adhost);
System.log(“OUs infomation Name3: ” + users);
return ou;
adhost is ad:AD:AdHost
I am seeing this error
Action ‘test_ou’ in module ‘Local.ActiveDriectory’ failed : TypeError: Cannot call method “indexOf” of undefined (Local.ActiveDriectory/test_ou#11)
Hello-
With the help of VMware support, i was able to search and filter AD user names. This is in VRA v8.3
To do this:
1. In the VRO action script, you must add a new input search string field. unde the properties section ont he right pane of your script. In my example, i labeled it userName
2, I then put my cursor between “User”and “adHost” and click on the input filed object up top so it will place it there as shown below:
var filter = System.getContext().getParameter(“__filter”);
var adHost = System.getModule(“com.vmware.library.microsoft.activeDirectory”).getDefaultAdServer();
System.debug(adHost);
var users = ActiveDirectory.search(“User”,userName,adHost);
return users
3. Next, go to your custom form, and create a new text field, label it “AD Search Criteria”
4. Click on your value picker field box, under Values tab, set value options to External Source, find your VRO action. Now you will see Action Inputs field appear. Select the drop down menu next to Field and expand Canvas Fields, then choose “AD Search Criteria” Save the form
Now the value picker box will return filter against what you enter in the AD search criteria box. You can enter in last name sicne it is an AD user field.
Hope this helps