vRA 7 – Getting more information in workflows from the vRO ExecutionContext object

When a vRO workflow or action is called from vRA, additional input parameters (in addition to those specified as the workflow/action inputs) are provided in the Execution Context object of the workflow. These can be very useful as they contain additional data that can be used inside the workflows. A couple of good examples would be the user that requested the resource or the name of the tenant.

All code that I have provided or talked about in this post can be downloaded as a vRO package for your consumption here.

Parameters Available

Here is a list of parameters provided inside the Execution Context (those without a description I’m still trying to figure out) of a workflow that has been executed by the Event Broker during VM provisioning.

 Parameter Name  Description
__asd_catalogRequestId The Request ID (vCAC Entity object reference)
__asd_correlationId  The Request ID (vCACCAFE object reference)
__asd_requestInstanceTimestamp Request Date & Time (UTC)
__asd_requestInstanceTypeId The lifecycle event topic id i.e. com.vmware.csp.iaas.blueprint.service.machine.lifecycle.provision
__asd_requestedBy The UPN of the user who made the request
__asd_requestedFor The UPN of the user the request was on behalf of
__asd_targetResourceId The vCAC virtual machine entity id
__asd_targetResourceTypeId Type ID, i.e. ‘machine’
__asd_targetResourceProviderTypeId com.vmware.csp.iaas.blueprint.service
__asd_tenantRef The id of the tenant (same id which goes in the url)

If anyone can shed some light on what the other parameters do then please comment and I’ll update the page.

You can also see these in the variables tab for the workflow run:

There is also another parameter which does not appear:

 Parameter Name  Description
__asd_subtenantRef The business Group id

This parameter is used to identify the business group which the user who submitted the request is a member of. For some reason this isn’t made available like the above parameters but only becomes available when you create and submit an XaaS Blueprint (a catalogue request mapped directly to a workflow).

The only workaround that I have used to get Business Group information available in Event Broker subscriptions is to create a custom property on each business group called ‘Custom.Business.Group.Name’ with the string name of the business group. It’s not a great solution but it does allow the custom property to be queried in the usual way.

Retrieve Parameter Values

There are two ways that you can retrieve the values from these parameters. The first is to simply add these parameters as an input to the workflow. vRA will automatically detect and populate these parameters with the corresponding values. You can then use these inputs as you normally would in your workflow.

The second option is to retrieve them from the Execution Context object.

Workflow Execution Context

The parameters and their values in the execution context object can be retrieved using the System scripting class. There is a method called ‘getContext()‘, which returns an object called ‘ExecutionContext‘. The ExecutionContext object has a ‘getParameter’ method which can be used to retrieve the value for the specified parameter.

Insert the following code into a scripting task in your workflow to list all the parameters and their values:

var executionContext = System.getContext();

System.log("\nExecution context Parameters:"
for each (var parameter in executionContext.parameterNames().sort()) {
    System.log(parameter + " : " + executionContext.getParameter(parameter))

Retrieve the Value for a Specific Parameter

To retrieve a value for a specified parameter the following example can be used:

Retrieves the tenant identifier and sets it to a variable ‘tenant’.

var tenant = System.getContext().getParameter("__asd_tenantRef");

Retrieve Parameter Values using Actions

I always like to do everything using Actions as I like to write my code once and simply re-use them repeatedly by dropping them onto my workflows. I have created a collection of Actions that can be used to get values from the Execution Context. As always, a link is provided to all my code at the beginning of this page.

I have a ‘core’ helper Action that will do the main work of retrieving the parameter value. This is a generic Action for getting a value from the Execution Context and is not directly related to vRA.


/*global parameter*/

 * Retrieves the value for the specified parameter in the Execution Context.
 * @author Gavin Stephens <gavin.stephens@simplygeek.co.uk>
 * @version 1.2.0
 * @function getExecutionContextParameterValue
 * @param {string} parameter - The Execution Context parameter.
 * @returns {string} Returns the parameter value.

function checkParams(parameter) {
    var inputErrors = [];
    var errorMessage;
    if (!parameter || typeof parameter !== "string") {
        inputErrors.push(" - parameter missing or not of type 'string'");
    if (inputErrors.length > 0) {
        errorMessage = "Mandatory parameters not satisfied:\n" + inputErrors.join("\n");

var logType = "Action";
var logName = "getExecutionContextParameterValue"; // This must be set to the name of the action
var Logger = System.getModule("com.simplygeek.library.util").logger(logType, logName);
var log = new Logger(logType, logName);
var paramValue = "";

try {
    log.debug("Getting value for parameter '" + parameter + "'");
    paramValue = System.getContext().getParameter(parameter);
    if (paramValue) {
        log.debug("Found parameter value: " + paramValue);
    } else {
        log.error("Could not find value for parameter '" + parameter + "'");
} catch (e) {
    log.error("Action failed to get parameter value.",e);

return paramValue;

The following Action is a wrapper for the ‘getExecutionContextParameterValue‘, that is used to get a value for a specific parameter.


 * Returns the value for the parameter '__asd_tenantRef'.
 * @author Gavin Stephens <gavin.stephens@simplygeek.co.uk>
 * @version 1.1.0
 * @function getTenantRefParameterValue
 * @returns {string} Returns the parameter value.

var logType = "Action";
var logName = "getTenantRefParameterValue"; // This must be set to the name of the action
var Logger = System.getModule("com.simplygeek.library.util").logger(logType, logName);
var log = new Logger(logType, logName);
var parameter = "__asd_tenantRef";
var paramValue;

try {
    log.log("Getting value for parameter '" + parameter + "'");
    paramValue = System.getModule("com.simplygeek.library.vro.workflow").getExecutionContextParameterValue(parameter);
    if (!paramValue) {
        log.error("No value was found for parameter '" + parameter + "'");
    log.log("Found parameter value '" + paramValue + "'");
} catch (e) {
    log.error("Action failed to get value for parameter '" + parameter + "'",e);

return paramValue;
[2019-01-31 22:47:07.909] [I] [Action: getTenantRefParameterValue] Getting value for parameter '__asd_tenantRef'
[2019-01-31 22:47:07.926] [D] [Action: getExecutionContextParameterValue] Getting value for parameter '__asd_tenantRef'
[2019-01-31 22:47:07.929] [D] [Action: getExecutionContextParameterValue] Found parameter value: sg
[2019-01-31 22:47:07.934] [I] [Action: getTenantRefParameterValue] Found parameter value 'sg'

You would simply drop this Action on to your workflow and set the output to store the parameter value.

I have included all the above Actions plus those required to retrieve all parameter values.

As always, if you need any help then please drop me a message via the Drift app.

0 0 votes
Article Rating

Related Posts

Notify of

Newest Most Voted
Inline Feedbacks
View all comments
6 years ago

I am currently trying to fetch the tenant details depending on the context,
I have added the following part in my script
var tenant = System.getContext().getParameter(“__asd_tenantRef”);

but it returns a null value..
Do we require any specific configurations before this(I have added a VRA host)?

6 years ago

thanks for your response, removing and re-typing the quotes worked.

Vaibhav Srivastava
Vaibhav Srivastava
5 years ago

__asd_requestedBy can this value be changed

5 years ago

“Wait, where is ‘__asd_subtenantRef’? More on that in my post here (soon).” I cannot find any reference to this.
Could you provide insight on this? Thanks.