How do you include the Short Description as part of the @mention Email?

zag
Tera Expert

I want the Short descritpion to follow email shown here. 

You have been mentioned by Root Mathew Xagoraris in CS0026575   "Short Description" 

 

 

this is my current code, any thoughts? The code below is in Notification Scripts.  Note I added current.short_description in the script below, everything but that works.  

 

var recordGR = new GlideRecord(current.table);

var field = current.field_name;

if(recordGR.get(current.document)) {

email.setSubject("You have been mentioned in " + recordGR.getDisplayValue());

template.print("<p style='color: #424E5B;margin: 0 0 12px;line-height: 26px;margin-bottom: 12px'>You have been mentioned by " + current.user_from.name + " in <a href='/" + recordGR.getRecordClassName() + current.short_description +".do?sys_id=" + recordGR.getUniqueValue() + "'>" + recordGR.getDisplayValue() + "</a></p>" + '<br>' + 'Comments: ' + current.document[field].getJournalEntry(1));

}

1 ACCEPTED SOLUTION

Matthew Smith
Kilo Sage

Hi zag

The current object is the live_notification table and this table does not have a short_description field, which is why current.short_description returns undefined. You need to use recordGR.short_description instead - the below seems to work for me:

var recordGR = new GlideRecord(current.table);
if(recordGR.get(current.document)) {
template.print("<span style='font-size: 10pt; font-family: verdana, geneva;'>You have been mentioned by " + current.user_from.name + "in <a href='/" + recordGR.getRecordClassName() + ".do?sys_id=" + recordGR.getUniqueValue() + "'>" + recordGR.getDisplayValue() + ' "' + recordGR.short_description + '"' + "</a></p>");
}

- Matt

View solution in original post

7 REPLIES 7

Jeff Currier
ServiceNow Employee
ServiceNow Employee

You cannot have the two </a>s.  How does this work?

 

var recordGR = new GlideRecord(current.table);

var field = current.field_name;


if(recordGR.get(current.document)) {

email.setSubject("You have been mentioned in " + recordGR.getDisplayValue());

template.print("<p style='color: #424E5B;margin: 0 0 12px;line-height: 26px;margin-bottom: 12px'>You have been mentioned by " + current.user_from.name + " in <a href='/" + recordGR.getRecordClassName() + ".do?sys_id=" + recordGR.getUniqueValue() + "'>" + recordGR.getDisplayValue() + "</a> : " + recordGR.get(current.short_description) + "</p><br> Comments: " + current.document[field].getJournalEntry(1));

Matthew Smith
Kilo Sage

Hi zag

The current object is the live_notification table and this table does not have a short_description field, which is why current.short_description returns undefined. You need to use recordGR.short_description instead - the below seems to work for me:

var recordGR = new GlideRecord(current.table);
if(recordGR.get(current.document)) {
template.print("<span style='font-size: 10pt; font-family: verdana, geneva;'>You have been mentioned by " + current.user_from.name + "in <a href='/" + recordGR.getRecordClassName() + ".do?sys_id=" + recordGR.getUniqueValue() + "'>" + recordGR.getDisplayValue() + ' "' + recordGR.short_description + '"' + "</a></p>");
}

- Matt

that did it thanks @JeffCsn  and @Matthew Smith