Highlighted
Micro Focus Expert
Micro Focus Expert
398 views

Unable to return Approver name in HTML Notifications

Jump to solution

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.

HTML_Err.JPG

Pls suggest!!

Thanks

Neo

0 Likes
1 Solution

Accepted Solutions
Highlighted
Acclaimed Contributor.
Acclaimed Contributor.

Re: Unable to return Approver name in HTML Notifications

Jump to solution

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.

---
Moving on, this account is no longer active. Best regards, Kelalek
- So Long, and Thanks for All the Fish

View solution in original post

0 Likes
15 Replies
Highlighted
Acclaimed Contributor.
Acclaimed Contributor.

Re: Unable to return Approver name in HTML Notifications

Jump to solution
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.”
0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

Re: Unable to return Approver name in HTML Notifications

Jump to solution

Thanks TomPowe for the suggestion

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

Thanks

Neo

0 Likes
Highlighted
Acclaimed Contributor.
Acclaimed Contributor.

Re: Unable to return Approver name in HTML Notifications

Jump to solution
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.”
0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

Re: Unable to return Approver name in HTML Notifications

Jump to solution

Thanks Again TomPowe,

 

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

Thanks

Neo

0 Likes
Highlighted
Acclaimed Contributor.
Acclaimed Contributor.

Re: Unable to return Approver name in HTML Notifications

Jump to solution

Can you provide some screenshots?

0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

Re: Unable to return Approver name in HTML Notifications

Jump to solution

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

3.JPG

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

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

0 Likes
Highlighted
Acclaimed Contributor.
Acclaimed Contributor.

Re: Unable to return Approver name in HTML Notifications

Jump to solution

Can you give us screenshots of the code itself? 

0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

Re: Unable to return Approver name in HTML Notifications

Jump to solution

Hi Tompowe,

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

Expressions_TAB.jpeg

//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

 

0 Likes
Highlighted
Acclaimed Contributor.
Acclaimed Contributor.

Re: Unable to return Approver name in HTML Notifications

Jump to solution

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.

0 Likes
Highlighted
Acclaimed Contributor.
Acclaimed Contributor.

Re: Unable to return Approver name in HTML Notifications

Jump to solution

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.

---
Moving on, this account is no longer active. Best regards, Kelalek
- So Long, and Thanks for All the Fish

View solution in original post

0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

Re: Unable to return Approver name in HTML Notifications

Jump to solution

Hi Kelalek2,

Im not sure for teh additional curly braces appearing, but in my enviornment these are not present.

For the  "Why the for loop exists if the $RECORD.current_pending_groups[0] is already fixed to use the first row in the array."

Commented the for loop as below. After that oit started working:

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

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.