Quantcast
Channel: VMware Communities: Message List
Viewing all articles
Browse latest Browse all 168455

Re: Get the Request ID shown in vRA into an email

$
0
0

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());
}

Viewing all articles
Browse latest Browse all 168455


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>