email script redirection

Fidel Fernandez
Tera Expert

Hi everyone.

I need some help, y make a email script and i try to redirect to Agent workspace to the specific record:

 

I make a modification in ng_activity_mention_body

 

(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */
email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */
event) {

var result = new ActivityMentionEmailValues().getEmailValues(current.table, current.document);
if (result) {
result = JSON.parse(result);
email.setSubject(gs.getMessage("You have been mentioned in {0}", result.subjectText));
template.print("<p style='color: #424E5B;margin: 0 0 12px;line-height: 26px;margin-bottom: 12px'>");
template.print(gs.getMessage("You have been mentioned by {0} in", current.user_from.name));

template.print("&nbsp;<a href='/now/workspace/agent/record/" + current.getTableName() + '/' +current.sys_id +"'>" + result.linkText + "</a></p>");

}

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

 

But when i click in the link take me to Agent workSpace but  current.getTableName() = live_notification

 

https;//ServicenowInstanceName/now/workspace/agent/record/live_notification/SysID(Incident or request)

2 REPLIES 2

Tony Chatfield1
Kilo Patron

Hi, the 'current' table will be the table of the notification that is calling your notification email script, and so I don't see anything incorrect or unexpected with the result.

/sysevent_email_action_list.do?sysparm_query=active%3Dtrue%5Emessage_htmlLIKEng_activity_mention_body&sysparm_view=

 

I think you need to map to the field 'table' on the current record, so that you get the table of the originating record and not the current table name which is always going to be live_notification, your sys_id mapping also needs to be updated as you are mapping the live_notification record and not the originating record.

 

Untested but try

template.print("&nbsp;<a href='/now/workspace/agent/record/" + current.table + '/' +current.document +"'>" + result.linkText + "</a></p>");

}

 

Fidel Fernandez
Tera Expert

I finally found a solution, the problem was "recordSysId ", line 14 and it's works

 

template.print("&nbsp;<a href='now/sow/record/"  + result.className  + '/' + result.recordSysId +"'>" + result.linkText + "</a></p>");