How to get the reference record for Group approvals?

ArpitaVK
Tera Expert

I have a Notification 'Approval request for exception' which is OOB on Approvals [sysapproval_approver] table. It contains the Notification email script 'sn_vul_exception_request_to_group'. Now, that I have changed the Notification table to Group Approval [sysapproval_group], the body of Notification is now blank as it is not getting any reference record. 

var appr_Record = current.document_id.getRefRecord();
var vul_record = appr_Record.vul_record.getRefRecord();
These are the two lines from where it was getting the reference record. Now that I have changed the Notification table to Group Approval [sysapproval_group], how can I get the reference of the record for which approvals are getting created?
5 REPLIES 5

@ArpitaVK 
try this code now 

(function runMailScript(current, template, email, email_action, event) {

var subject, body, vulRecordLink, reqDetails, vulDetails;
var util = new VREmailUtils();

// Retrieve the referenced record from the 'parent' field
var appr_Record = current.parent.getRefRecord();

// Retrieve the referenced record from the 'vul_record' field on the 'appr_Record'
var vul_record = appr_Record.vul_record.getRefRecord();

// Get the link to the vulnerability record
vulRecordLink = util.getVulLink(vul_record);

// Split the 'approvers_list' into an array if it's not empty
var approversArr = appr_Record.approvers_list != '' ? appr_Record.approvers_list.split(","): '';

// Construct the email body
body = gs.getMessage("Hi Exception Approver,<br/><br/>An exception request has been submitted by {0} on {1} to defer {2}.<br/><br/>Please review and approve this request as soon as possible. Additional details are as follows:<br/><br/>", [util.getUserName(appr_Record.requested_by), '${sys_created_on}', vulRecordLink]);
template.print(body);

// Print approver details if there are any
if(approversArr.length > 0){
appDetails = gs.getMessage("Approver name: {0}<br/><br/>", [util.getUsersName(approversArr)]);
template.print(appDetails);
}

// Print request details
reqDetails = util.getRequestDetailsForException(appr_Record);
template.print(reqDetails);

// Print vulnerability details
vulDetails = util.getVulnerabilityDetails(vul_record);
if (vulDetails) {
template.print(vulDetails);
}

})(current, template, email, email_action, event);