ljm69
Contributor
Contributor

Service broker - project field drop down on the new request form

Jump to solution

Hi,

I was wondering if anyone can explain how the project field drop down works.

We name our projects by team, and would like to use the project friendly name that you choose during a new request.

I can see its set to external action, but there's nothing about what that external action is.

Is there any way to use that as a customProperty as part of your blueprint? For example the inputs I've setup are on the form so could you use the project selection here to set things that you'd otherwise do via an input on the blueprint (via a workflow or action I guess?) I currently have owner setup as an input for now in the form as a workaround, which obviously works as expected! But it seems like I'm missing something when the input will already be selected somewhere else.

I'd also like to use the project friendly name as part of an auto deploy name. I've used the example from v12n.io which works great however if I select project as one of the fields for my external inputs its sets it to the unique ID.

Maybe once I understand how I could reuse the friendly project name that could auto fill in my owner input on the form as well to pass to the blueprint and then just hide the owner field on custom form? (just thinking out loud, I maybe completely wrong!)

I'm clearly missing something in my learning curve for VRA8 here but hopefully someone knows what silly thing I'm doing or missing!

Thank you!

 

0 Kudos
1 Solution

Accepted Solutions
xian_
Expert
Expert

You can use vRA API to get the project name from project ID. The easiest method is to leverage the vRA plugin of vRO.

Here is a code from the plugin you could reuse from com.vmware.vra.extensibility.plugin.rest.project/getProject:

 

 

var url = "/project-service/api/projects/" + projectId;
var parameters = null;
var project = System.getModule("com.vmware.vra.extensibility.plugin.rest").getObjectFromUrl(vraHost, url, parameters);
return project;

 

 

You'd have to return the project name, not the whole project object (so that you can use it as an action calculating a default value).

View solution in original post

3 Replies
xian_
Expert
Expert

You can use vRA API to get the project name from project ID. The easiest method is to leverage the vRA plugin of vRO.

Here is a code from the plugin you could reuse from com.vmware.vra.extensibility.plugin.rest.project/getProject:

 

 

var url = "/project-service/api/projects/" + projectId;
var parameters = null;
var project = System.getModule("com.vmware.vra.extensibility.plugin.rest").getObjectFromUrl(vraHost, url, parameters);
return project;

 

 

You'd have to return the project name, not the whole project object (so that you can use it as an action calculating a default value).

ljm69
Contributor
Contributor

Hi xian,

Thank you for replying.

I also stumbled across this blog about using the vRA plugin and something extremely similar too.

https://tg-test100.com/using-the-vra-plugin-for-vro-enabling-actions-in-custom-forms-which-call-the-...

I think it uses an older /iaas url? Which obviously worked. But I used your url suggestion as it seems the newer way of doing things? Which also works!

But I have something working now and I also now have a better understanding on how to go grab other custom properties too from a project, which should prove useful elsewhere too. One question that springs to mind is if I did use this same action for multiple inputs on a form for example (say to grab a custom property on a project i wanted to use in another input), would that be a single action run, or an action run for each input? Obviously if it was the latter then I'd guess this would then be the wrong way of doing it?

I probably need to understand rest calls in general without the convenience of the vRA plugin and understaning how to set auth headers though. If you have any recommended blogs I could learn from from feel free to suggest! The whole vRO thing using inputs and outputs in workflows is my current  (steep!) learning curve without a doubt!

One thing with the code from the above blog, the timeout for when a project is not yet selected in the form for me seemed to take a long time before I could then actually choose a project from a forms drop down list. There is a little timeout near the bottom of the code I tweaked to make Project selectable a lot quicker. No doubt something obvious to someone like yourself, but for me it wasn't! Small steps..!

Many thanks,

0 Kudos
xian_
Expert
Expert

I've read it somewhere (API docs or release notes) that the project API was moved off /iaas

Each reference to your action on a CF results an action run.

If you are interested in getting and using a vRA API token, check out vRealize Automation 8.5 API Programming Guide 

If you want to get and set tokens from vRO, look for the setHeader method of the request object. You can search for some examples in the forum or blogs...