VMware Cloud Community
aamodei01
Enthusiast
Enthusiast

Get the Request ID shown in vRA into an email

Hello and thanks in advance!

I'm trying to get the request number from the vRA request (specifically when a user requests a new server) and i want to pump that to Orchestrator to insert into an email.

Has anyone done this?

Also, has anyone else abandoned the vRA built in emails and created your own in orchestrator? How did you format the scripting in vRO for html formatted emails with vra variables?

7 Replies
vMarkusK1985
Expert
Expert

Hi,

do you use vCO?

We add the Request ID in some ASD email notifications.

Code Snippet for creating an HTML Email Body:

subject = "[Action Required] - User Request";

sendTo = "ALERT@mail.com"

body = "Request Details:  \n"

  + " \n"

  + "Titel " + new_user_titel + " \n"

  + "Name: " + new_user_firstaname + " \n"

  + "Notes:  \n"

  + request_notes + " \n \n"

  + "Request ID: " + __asd_catalogRequestId + " \n"

  + " \n"

  + " \n"

  + "Requester Details \n"

  + "Requested by: " + __asd_requestedBy + " \n";

For ASD vCO Workflows you can use these predefined inputs:

ASD.png

https://mycloudrevolution.com | https://twitter.com/vMarkus_K | https://github.com/vMarkusK
Reply
0 Kudos
aamodei01
Enthusiast
Enthusiast

Hey vMarkusK1985vMarkusK1985!

Thanks for the quick reply!

We are using vCO and Im new to all this and in the reading i've done thusfar (and I could be missing the point) those __asd... values seem to only exist when you are using an ASD based action/workflow, etc

I'm simply trying to bypass the build in vRA emails and build my own. One thing I'm stuck on is trying to get the request # that is generated when the user builds a vm into the subject line of my custom emails (similar to what the built in ones do now).

Reply
0 Kudos
vMarkusK1985
Expert
Expert

@aamodei01 I think your are right. Its only possible via a ASD...

Do you use a Stub to trigger your vCO custom email?

I send custom emails after provisioning in my enviroment, but I do not include the Request ID in these Mails...

For the "Request ID Problem" I have no solution at the moment.

But I think Object vCACCAFEEntitiesFinder is an option, there is a Method findRequests avaiable.

Use the API Explorer in vCO to dig in....

https://mycloudrevolution.com | https://twitter.com/vMarkus_K | https://github.com/vMarkusK
Reply
0 Kudos
tm19
Contributor
Contributor

If you do decide to use ASD, when you send your request back into VRA for provisioning using the 'requestCatalogItem' action, the output is a VCACCAFE:CatalogItemRequest, which had id, request dates, numbers etc.

Cheers

Reply
0 Kudos
SeanKohler
Expert
Expert

So I think maybe you are asking for Request ID... and describing Request Number?

Do you have RequestID but are lacking the Request Number?

var request = vCACCAFEEntitiesFinder.getCatalogItemRequest(CAFEHOST , requestID);

var requestNumber = request.getRequestNumber();


If you don't have either number...

Which workflow or workflow stub (extension) are you building this email in?   (or is it Async waiting on something to complete?)

The CAFE Resource object is created last in a successful run.  You can get the reference Request ID from that resource.  You can also do a little logical filtering to get to get a likely request candidate.  This represents the initial filter that you can use to get an array of request objects that fits within the criteria of values readily available in the extensible stubs.  You can filter on many fields for many different values to get the correct object back.  With correct object, you can get the ID and Request Number easily enough...

// Here are many filter examples.  You can pick and choose how best to limit your query
// to get back as few objects as possible.  From those objects, you can then better determine
// which object is required.
var filter = new Array();
filter[0] = vCACCAFEFilterParam.equal("requestedFor", vCACCAFEFilterParam.string("username@domain.com")); // available in the stubs
filter[1] = vCACCAFEFilterParam.equal("requestedBy", vCACCAFEFilterParam.string("user@domain.com")); // available in the stubs
// The below value is populated with the servername in Successful requests... and in MOST Failed requests. I have seen it blank before, but that is a failed state too.
filter[2] = vCACCAFEFilterParam.substringOf("requestCompletion/completionDetails", vCACCAFEFilterParam.string("ServerName")); // available in the stubs
// This is the  part of the complex property that shows Failed or Successful based on completion. Per the schema.xsd document, there are only
// two states for this property.
filter[3] = vCACCAFEFilterParam.substringOf("requestCompletion/requestCompletionState", vCACCAFEFilterParam.string("SUCCESSFUL")); //OR FAILED

// dump the filter array into a query object
var query = vCACCAFEOdataQuery.query().addFilter(filter);

//get a pageable request back of the objects from the query
var filteredRequests = service.getRequests(new vCACCAFEPageOdataRequest(query));

// to get from the pageable format to the VCO objects use .getContent()
// which gets you an array of the object types.  It will be a short array
// because we filtered out all the junk above.  Ideally it would be an array
// of ONE object if our filter was written to meet our requirements.
for each (filteredRequest in filteredRequests.getContent()){
System.log(filteredRequest.getRequestNumber() + " : "
   + filteredRequest.getDateSubmitted() + " : "
   + filteredRequest.getId());
}

kumarsenthild
Enthusiast
Enthusiast

Thank you. i was trying to get User request number.

Regards Senthil Kumar D
Reply
0 Kudos
balawiz
Enthusiast
Enthusiast

How do we get the failed catalog requests request number or ID? using the following failed completion payload properties(including __asd)? I am not able to match the below requestId or deploymentId with vRA catalog request details.

Failed Payload properties:

{taskType=PROVISION, subtenant=92c2bd1a-********, completionDetails=The following component requests failed: some failed reason...

....

...

requestId=c25eef16-2*********, success=false, deploymentId=68238be4-************, blueprintId=test, tenant=testTenent, requestStatus=FAILED}

'__asd_requestInstanceId'

'__asd_catalogRequestId'

'__asd_targetResourceId'

'__asd_correlationId'

'__asd_requestTraceId'

'__asd_requestTraceId'

Reply
0 Kudos