Adding Approval Comments to html email template

We are using approvals with the Service Catalog while the record is still an interaction. I have created an html email that will send if the record receives a denial, but I would like to include those approval comments or data from the approval log in the email.

these fields are in the incidents table :

Approval Comments field=$L.aplItem.comments

Approval Log field=action

I am unable to get the information to show in the email

We are using SM HPE 9.50 with Process Designer

 

  • Verified Answer

    Hi a2drew,

    One option to display information from another record in the htmltemplate is to use the id of the interaction to query the ApprovalLog table and bring the Comments to a variable in the htmltemplate code. The code in the htmltemplate can be something like this:


    var id="SD10114"
    var aplog= new SCFile("ApprovalLog");
    var rc=aplog.doSelect("unique.key=\"" id "\"");
    var comments="";
    if (rc==RC_SUCCESS)
    {
        comments=aplog.comments;
    }

    Note: The variable id, needs to be set based on your htmltemplate code.

    the variable comments needs to be added in the html Source,

    I hope this helps.

    Best regards,

  • The expression I had was:

    //Localize local module status value
    var file_name = system.functions.filename($RECORD);
    var _open = $RECORD.open;
    var _approvalStatus = $RECORD.approval_status;

    var open = lib.htmlemailtemplates.getLocalStatusValue($RECORD, _open)
    var approval_status = lib.htmlemailtemplates.getLocalizedApprovalStatus(_approvalStatus);
    var display= lib.MailUtil.isRequestDetailSectionDisplay();

    //#######################
    var interaction_id;
    if (file_name === "incidents") {
      interaction_id = $RECORD.incident_id;
    }
    else if (file_name === "Approval") {
      interaction_id = $RECORD.unique_key;
    }

    var interaction_record = new SCFile("incidents", SCFILE_READONLY);
    interaction_record.setFields(['title','description','contact.name','open','cartId']);
    interaction_record.doSelect('incident.id="' interaction_id '"');
    var service_recipient = interaction_record.contact_name;
    var interaction_status = interaction_record.open;
    var interaction_title = interaction_record.title;
    var interaction_desc = interaction_record.description;

     

    So would I add it in like this:?

    //#######################
    var interaction_id;
    if (file_name === "incidents") {
      interaction_id = $RECORD.incident_id;
    }
    else if (file_name === "Approval") {
      interaction_id = $RECORD.unique_key;
    }
    var aplog= new SCFile("ApprovalLog");
    var rc=aplog.doSelect("unique.key=\"" id "\"");
    var comments="";
    if (rc==RC_SUCCESS)
    {
        comments=aplog.comments;
    }

    var interaction_record = new SCFile("incidents", SCFILE_READONLY);
    interaction_record.setFields(['title','description','contact.name','open','cartId']);
    interaction_record.doSelect('incident.id="' interaction_id '"');
    var service_recipient = interaction_record.contact_name;
    var interaction_status = interaction_record.open;
    var interaction_title = interaction_record.title;
    var interaction_desc = interaction_record.description;

  • Your solution was right, I just needed to update my id variable

    From:

    var rc=aplog.doSelect("unique.key=\"" id "\"");

    to:

    var rc=aplog.doSelect("unique.key=\"" interaction_id "\"");