VMware Cloud Community
DionRow
Enthusiast
Enthusiast
Jump to solution

VRO 8.1 Powershell VRA 8.1 Custom Forms

In previous versions of VRO and VRA 8.0 only js was available to write VRO actions to respond to VRA custom form external sources.

With the addition of powershell as a VRO language we are attempting to leverage this as most of our work is already done in powershell.

I am unable to get a value returned from the powershell script into VRA Service Brokers custom forms

What is the problem with the following powershell code to return a 1/ simple string and 2/ a array of options for a dropdown selector?  Any example docs or blogs on this would be helpful as I am not finding much.

1/

function Handler($context, $inputs) {

    $inputsString = $inputs | ConvertTo-Json -Compress

    Write-Host "Inputs were $inputsString"

   $output="theStringValue"

   return $output

}

2/

function Handler($context, $inputs) {

    $inputsString = $inputs | ConvertTo-Json -Compress

    Write-Host "Inputs were $inputsString"

    $output = @()

    $output[0] = "Test1"

    $output[1] = "Test2"

    return $output

}

thanks

-- dion VMware Systems Admin vExpert VMUG Leader Saskatoon
0 Kudos
1 Solution

Accepted Solutions
lnairn
VMware Employee
VMware Employee
Jump to solution

Hi,

For the point 1, I've tested this in my environment and works as expected:

I've created an action with your code, with return type string and I've used that action to populate a variable in service broker

Regarding the second point, you can use a properties variable as output for the action and that works for dropdown without issues.

My action is:

function Handler($context, $inputs) {

$values = @{ A = 'a'; B = 'b'}

$theObject = new-object psobject -Property $values

write-host $theObject

return $theObject

}

Return type: Properties

I've configured this action in service broker "Customize Form" for a Bluprint and works well for dropdown variables.

Regards,

Leandro.

View solution in original post

0 Kudos
3 Replies
lnairn
VMware Employee
VMware Employee
Jump to solution

Hi,

For the point 1, I've tested this in my environment and works as expected:

I've created an action with your code, with return type string and I've used that action to populate a variable in service broker

Regarding the second point, you can use a properties variable as output for the action and that works for dropdown without issues.

My action is:

function Handler($context, $inputs) {

$values = @{ A = 'a'; B = 'b'}

$theObject = new-object psobject -Property $values

write-host $theObject

return $theObject

}

Return type: Properties

I've configured this action in service broker "Customize Form" for a Bluprint and works well for dropdown variables.

Regards,

Leandro.

0 Kudos
DionRow
Enthusiast
Enthusiast
Jump to solution

Thanks. 

I actually just realized that changes I was making were not being realized in the catalog.  I noticed that the "enable" link was back (even though the custom form had already been enabled).  I clicked it again and saved and all is working now.  This may be a bug but I haven't seen it happen again, but will keep watching and if it happens again will file an SR.

Thanks again.

-- dion VMware Systems Admin vExpert VMUG Leader Saskatoon
0 Kudos
VinithMenon
VMware Employee
VMware Employee
Jump to solution

can you add a screenshot to illustrate how you made the dropdown work ?

0 Kudos