slideshow 6 slideshow 4 slideshow 8 slideshow 1 slideshow 2 slideshow 3 slideshow 5 slideshow 7

vRealize Automation 7 External Approval Policy with vRealize Orchestrator Workflow

With vRealize Automation 7 an Approval Policy can be linked to an event subscription that in turn can trigger a vRealize Orchestator workflow to perform an external approval process. In this article I describe how to setup the Workflow, the Approval Policy and the Event Subscription.

Workflow as downloadable package

This article is based on the vRealize Automation 7 Documentation where a scenario is described for an external approval: 

Scenario: Create a vRealize Orchestrator Workflow for Approval Workflow Subscriptions

I have modified that scenario to create a workflow approval for Virtual Machine requests and added more clarification and the necessary code examples to build it yourself.

In this working example I use a vRealize Orchestrator Workflow with a User Interaction element to handle the approval request. But you can of course modify this behavior to have the vRO Workflow send the request to an external system, for example via the HTTP Rest API and wait for the approval result.

The first step is to build the vRealize Orchestrator Workflow, that will look like this:

vRealize Automation 7 External Approval Workflow

The workflow uses the attributes from the next image to store data during the workflow.

vRealize Automation External Approval Policy

The workflow requires one input parameter. In the next image it is named payload and it is of the type Properties. This is a data type that will contain all fields coming from vRA.

vRealize Automation External Approval Policy

There are two required output parameters: approved, a boolean to report the approval decision (yes/no) back to vRA and fieldValues of the Properties type that will contain the Business Justification for the approvers response to the request.

vRealize Automation External Approval Policy

The first scripting element in the workflow gets the required data from the payload properties object that came from vRA.

vRealize Automation External Approval Policy

Here is the Javascript code from this element:

//get the Properties-object with the requestinfo
var requestInfo = new Properties;
requestInfo = payload.get("requestInfo");
//get the info we need from the request
itemName = requestInfo.get("itemName");
reason = requestInfo.get("reason");
requestedBy = requestInfo.get("requestedBy");
description = requestInfo.get("description");

This next element is the User Interaction element. It requires the two External Inputs from the next image: approved and businessJustification.

You can also add the other fields that are updated in the previous scripting element as Attributes that you can use in the Presentation of this element.

vRealize Automation External Approval Policy

The third and final element is a scripting element that will update the fieldValues output parameter with the businessJustification answer form the approver.

vRealize Automation External Approval Policy

This is the Javascript code from this element:

//put the business justification in the fieldValues 
//properties object and set it as an output parameter
var fieldValues = new Properties;
fieldValues.put("businessJustification",businessJustification);

Now that we have the vRealize Orchestrator Workflow in place it's time to setup the Approval Policy. Login to the vRealize Automation Console and from the Administration tab select Approval Policies and click the green plus-sign to create a new policy. Choose a policy for a Service Catalog Item Request for a Virtual Machine. This is necessary for this example because it is based on VMs but you can of course also build policies for other types of requests.

vRealize Automation External Approval Policy

Provide a name for the policy and click the green plus-sign 

vRealize Automation External Approval Policy

In this example I use a Pre Approval level that will only provision a machine after the request has been approved. In the next image you see that I have configured the policy to always require approval. You can of course use conditions for when you need approval. The most important setting is on the right hand side of the image, which is the Use event subscription setting, which is new in version 7.

vRealize Automation External Approval Policy

Don't forget to set the policy to Active.

vRealize Automation External Approval Policy

After saving the Approval Policy go to the Events item in the Administration menu to create a new subscription. The type you need to select for this example is a Pre Approval event topic.

vRealize Automation External Approval Policy

It is possible to subscribe to the event and execute your workflow for all requests, but in this example I have limited it to Virtual Machines only with the condition from the image below.

vRealize Automation External Approval Policy

In the next step point to the vRealize Orchestrator Workflow you have created earlier.

vRealize Automation External Approval Policy

In the final step provide a name for the subscription.

vRealize Automation External Approval Policy

Now that you have the policy and the subscription configured add the Approval Policy to a service or catalog item in the Service entitlement.

vRealize Automation External Approval Policy

Now it is time to request a new item. The description and reason will be sent to the vRealize `orchestrator workflow.

vRealize Automation External Approval Policy

Here is the request in vRealize Orchestrator:

vRealize Automation External Approval Policy

For the user to see the result open the Items list, click on the request number at the beginning of the line and in the request details window click on the Rejected link on the left to see the result of the approval process.

vRealize Automation External Approval Policy

The user will also receive a message about the approval process if notifications and the email server have been configured.

vRealize Automation 7 External Approval

Follow us on LinkedIn