Unable to return Approver name in HTML Notifications

Hi All,

We are having HP service Manager 9.41, wherein we are sending a pending for Approval HTML notifications.

I have placed the below code for returning the Approver name , since current pending groups consists of Login ID which makes difficult for the requester to undertsand that to whom change is pending for approval.

Under expression TAB in HTML notifications:

var currentapp=system.functions.lng($RECORD.current_pending_groups);
if (currentapp>0) {
for(i=0;i<currentapp;i )
{
var contactFile = new SCFile("contacts",SCFILE_READONLY);
var rc4 = contactFile.doSelect("user.id=\"" $RECORD.current_pending_groups[1] "\"");
if (rc4 == RC_SUCCESS)
{
var fname = contactFile.full_name;
}

using the fname in Mail body is setting the preview in HTML notfications as null.

Pls suggest!!

Thanks

Neo

  • Try changing this line:

    var rc4 = contactFile.doSelect("user.id=\"" $RECORD.current_pending_groups[1] "\"");

    To:

    var rc4 = contactFile.doSelect("user.id=\"" $RECORD.current_pending_groups[0] "\"");


    Thomas S. Powe ∴
    PepsiCo, Inc | Global Service Management Technical Lead
    5600 Headquarters, Plano, TX 75024

    “A bird in a tree is never afraid of the branch breaking, because her trust is not in the branch but in her own wings. Always believe in yourself.”
  • Thanks TomPowe for the suggestion

    I tried the same , but it didn't work. Any other ideas.

    Thanks

    Neo

  • Maybe it’s just “null” when Previewing because at that moment $RECORD.current_pending_groups[0] is null; that doesn’t mean it’s going to be null when a notification goes through that code. Have you actually tested it to see what a real notification looks like now with my code suggestion change?

    Thomas S. Powe ∴
    PepsiCo, Inc | Global Service Management Technical Lead
    5600 Headquarters, Plano, TX 75024

    “A bird in a tree is never afraid of the branch breaking, because her trust is not in the branch but in her own wings. Always believe in yourself.”
  • Thanks Again TomPowe,

     

    While trying the same to view in notifcation only the subject line is appearing while mail body is absent

    Thanks

    Neo

  • Can you provide some screenshots?

  • Only email Id is appearing along with user id ,below is the screenshot

    But when the code in expression is commented out below is the mail that appears:

    there on the top right masked with Orange the approver ID is appearing.

  • Can you give us screenshots of the code itself? 

  • Hi Tompowe,

    Pls find attached exspression screenshot, alternatively I have copy the Expressions content below:

    //Prepare url for web access
    //#################################################################################################################
    //This is the url for index.do. if you want to generate url for ess.do, please use getESSURLFromQuery instead
    var file_name = system.functions.filename($RECORD);
    var record_name = system.functions.scmsg(file_name,"tablename");
    var record_title = record_name " " $RECORD.number;
    var record_query = "number=\"" $RECORD.number "\"";
    var web_url = lib.urlCreator.getURLFromQuery(file_name,record_query,record_title);
    //var web_url = lib.urlCreator.getESSURLFromQuery(file_name,record_query,record_title);
    //#################################################################################################################


    //#################################################################################################################
    //Generate Impact, Urgency, and Priority readable label

    var _priority = $RECORD.priority_code;
    var _severity = $RECORD.severity;
    var _impact = $RECORD.initial_impact;
    var _risk = $RECORD.risk_assessment;

    var priority="";
    var severity="";

    var impact="";
    var risk = "";


    switch(true)
    {
    case _severity==1:
    severity = "1 - Critical"; break;
    case _severity==2:
    severity = "2 - High"; break;
    case _severity==3:
    severity = "3 - Average"; break;
    case _severity==4:
    severity = "4 - Low"; break;
    }


    switch(true)
    {
    case _priority==1:
    priority = "1 - Critical"; break;
    case _priority==2:
    priority = "2 - High"; break;
    case _priority==3:
    priority = "3 - Average"; break;
    case _priority==4:
    priority = "4 - Low"; break;
    }

     

    switch(true)
    {
    case _impact==1:
    impact = "1 - Enterprise"; break;
    case _impact==2:
    impact = "2 - Site/Dept"; break;
    case _impact==3:
    impact = "3 - Multiple Users"; break;
    case _impact==4:
    impact = "4 - User"; break;
    }

    switch(true)
    {
    case _risk==0:
    risk = "0 - No Risk"; break;
    case _risk==1:
    risk = "1 - Low Risk"; break;
    case _impact==2:
    risk = "2 - Some Risk"; break;
    case _impact==3:
    risk = "3 - Moderate Risk"; break;
    case _impact==4:
    risk = "4 - High Risk"; break;
    case _impact==5:
    risk = "5 - Very High Risk"; break;
    }
    //var appname = system.library.KMUtils.scArrayToHTMLString($RECORD.current_pending_groups[1]);

    //#################################################################################################################
    //#################################################################################################################
    //Check if system require fulll operator name and if need append timezone to date time.
    var operator = $RECORD.operator;
    //#################################################################################################################
    var $ = lib.c.$;
    var current_phase = $("#datadictService").displayValue($RECORD,"current.phase");
    //###################################
    var currentapp=system.functions.lng($RECORD.current_pending_groups);
    if (currentapp>0) {
    for(i=0;i<currentapp;i )
    {
    var contactFile = new SCFile("contacts",SCFILE_READONLY);
    var rc4 = contactFile.doSelect("user.id=\"" $RECORD.current_pending_groups[0] "\"");
    if (rc4 == RC_SUCCESS)
    {
    var fname = contactFile.full_name;

    Thanks

    Neo

     

  • Can you put in a print statement to find out what "rc4", "fname" and $RECORD.current_pending_groups[0] (or current_pending_groups[1]) equals?.

    Assuming this is a background process, you'll want to use the "log" rad call and then look in the log.

  • Verified Answer

    var currentapp=system.functions.lng($RECORD.current_pending_groups);
    if (currentapp>0) {
    for(i=0;i<currentapp;i ) {
    var contactFile = new SCFile("contacts",SCFILE_READONLY);
    var rc4 = contactFile.doSelect("user.id=\"" $RECORD.current_pending_groups[0] "\"");
    if (rc4 == RC_SUCCESS) {
    var fname = contactFile.full_name;
    } 

    }

    }

    Does the code end up prematurely (copy/paste error)? Couple of } missing in the end to finish:

    • the for loop
    • if clause

    But I've to admit that I don't fully understand why the for loop exists if the $RECORD.current_pending_groups[0] is already fixed to use the first row in the array.