how to coppy approvallog.comments data to html temaplates

Hi,

We are setting up new templates to email requesters the reason when their requests are denied by the line manager (I know they can see this is the SRC, but they are lazy).

I need to setup a lookup for the comments in the ApprovalLog.Comments field when ApprovalLog.Action is Denied.  I know this is done in JavaScript and we have tried this, but it does not seem to pull any data.

var deniedstatus= vars.$l_file.approvallog_action;
var comments = vars.$l_file.approvallog_comments;
if (deniedstatus =="Denied") {
comments;

  • The bottom of my message got cut of.

    I think the vars.$l_file is not referencing correctly.  How do we lookup the ApprovalLog table and pull fields into the htmltemplate?

    Thank you for your assistance.

     

     

  • I do not have a Service Manager instance in front of me, so this is off the top of my head, but something like this should work:

    The notification record line which calls the htmltemplate should have a condition like approval.status in $L.file="denied" and not same(approval.status in $L.file,approval.status in $L.file.save).

    In the expressions tab of the htmltemplate, you should create an array variable - I'll call it approvalLog. The approvalLog variable should be populated thusly:

    var approvalLog = new Array();
    var log = new SCFile("ApprovalLog");
    //I *think* number and number are the correct fields; make sure you check them:
    //(the first "number" is the field on ApprovalLog; the second "number" is on request) var logRc = log.doSelect("number=\"" record.number "\""); while (logRc == RC_SUCCESS) { //Check the fieldname in ApprovalLog file of the approver who denied: approvalLog.push(log.approver); //Check the fieldname in ApprovalLog file of the date/time when the denial occurred: approvalLog.push(log.date); //Check the fieldname in ApprovalLog file of the comments given for the denial: approvalLog.push(log.comments); logRc = log.getNext(); }

    As I indicated in the commented lines, make sure you double-check that these fields are the correct ones for the request (number) and the ApprovalLog (number, approver, date, comments).

    Then, in the HTML Source tab of the htmltemplate, you can include the newly-populated variable as {approvalLog} wherever you want it to appear.