A few days ago I had the strange need to capture a requester’s business group in a custom property whilst provisioning resources in vRealize Automation.
Whilst obtaining this information post-provisoning is simple enough, I couldn’t find an obvious way to do this at first. Then I sat down and thought about it.
The requirement was to identify the business group at request time, as this along with some other properties, will be used with various extensibility tools to integrate with things like NSX and Site Recovery Manager.
As we’re running vRealize Automation 7.5 in HobbitCloud, I knew it was possible to leverage custom forms to get this information. However I wanted to avoid using those as I wanted to know how to solve the issue in either 7.2 or 7.3.
To get what I needed, I created a new module and action in vRO and set the return type to Array/String. I then used the following code:
var bg = new Array(); //Get the tenant and Business Group var tenant = System.getContext().getParameter("__asd_tenantRef"); var subtenantRef = System.getContext().getParameter("__asd_subtenantRef"); //Get the Cafe details var host = vCACCAFEHostManager.getDefaultHostForTenant(tenant, true); //Correlate the ID to a name var mysubtenant = vCACCAFEEntitiesFinder.getSubtenant(host, subtenantRef); var name = mysubtenant.name; bg.push(name); //Return the Business group name return bg;
I then created a new custom property (hc.businessGroup), with the following details:
Finally I selected my action from those available in vRO. Once complete I requested a catalog item and my custom property was automatically calculated:
To verify the action works as expected, if you select a different business group from the dropdown at the top, then the form will be redrawn and the action will be called again.