Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Trying to display Short Description in Mentioned Notification

Daniel O_Connor
Kilo Guru

Hi all,

Have been updating the OOB "You have been mentioned" notification to include some more information so the user can decide if they need to action immediately or at all. Have successfully brought in the actual comment that was made, but struggling to get the short description in

 

var recordGR = new GlideRecord(current.table);
if(recordGR.get(current.document)) {
	var displayValue = recordGR.getDisplayValue();
	var subjectText = displayValue
		? displayValue
		: "a record discussion";
	var tableDisplay = recordGR.getClassDisplayValue();
	var linkText = displayValue
		? "the " + tableDisplay  + " record " + displayValue
		: "this " + tableDisplay  + " record ";
	//Next line defines the Subject of the mail
	email.setSubject("You have been mentioned in " + subjectText);
	
	//Next line defines the Short Description
	template.print("Short Description: " + current.short_description.getDisplayValue()+ "<br />");
	
	//Next line defines the link to incident record
	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() + "'>" + linkText + "</a></p>");
	
	//This segment displays the actual comment in the notification mail
	if (current.field_name == "comments") {

              template.print(recordGR.comments.getJournalEntry(1) +   "<br />");

      }

      else if (current.field_name == "work_notes") {

              template.print(recordGR.work_notes.getJournalEntry(1) +   "<br />");

      }
}

Pretty sure I'm displaying the value of short description incorrectly, would love another set of eyes on this please.

Thanks as always!

1 ACCEPTED SOLUTION

SanjivMeher
Mega Patron
Mega Patron

Do you need to use

template.print("Short Description: " + recordGR.short_description.getDisplayValue()+ "<br />");

instead of 

template.print("Short Description: " + current.short_description.getDisplayValue()+ "<br />");


Please mark this response as correct or helpful if it assisted you with your question.

View solution in original post

4 REPLIES 4

Elijah Aromola
Mega Sage

You can just do current.short_description. .getDisplayValue is for reference fields, instead of displaying their value (sys_id) it will show their display value.

So seems to be just returning undefined in any test I do

 

find_real_file.png

 

//Next line defines the Short Description
	template.print("Short Description: " + current.short_description + "<br />");

SanjivMeher
Mega Patron
Mega Patron

Do you need to use

template.print("Short Description: " + recordGR.short_description.getDisplayValue()+ "<br />");

instead of 

template.print("Short Description: " + current.short_description.getDisplayValue()+ "<br />");


Please mark this response as correct or helpful if it assisted you with your question.

Thank you, this is working now perfectly

 

find_real_file.png