How to Include Fields from Other Tables in Notifications

TStark
Kilo Sage

I have a notification on the Demand table. How can I include the value of a field from the Requirement [dmn_requirement] table? Dot walking doesn't work as the two tables aren't directly related.

Thanks,
AJ

1 ACCEPTED SOLUTION

@TStark , try the below code

 

(function runMailScript(current, template, email, email_action, event) {
var demand = new GlideRecord("dmn_requirement");
demand.addQuery("demand", current.sys_id)
demand.query() //if its for one record
if(demand.next()){
template.print('Demand Requirement' + demand.short_description.getDisplayValue());
}
})(current, template, email, email_action, event);

Please Mark my answer Helpful & Accepted if I have answered your question.

Thanks,

Alka

 

View solution in original post

7 REPLIES 7

Ankur Bawiskar
Tera Patron
Tera Patron

@TStark 

if the 2 tables are not directly related, you need to know how they are linked and then use email script and print the fields from another table

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Hi @Ankur Bawiskar I appreciate your response. I'm aware that an email script will be needed, but the problem is I don't know what that email script will look like when trying to associate these two tables (dmn_demand and dmn_requirement) for the notification.

Thanks,
AJ

Alka_Chaudhary
Mega Sage
Mega Sage

Hello @TStark ,

How two tables (dmn_demand and dmn_requirement) are related with each other and which all fields of dmn_requirement table you want on the notification, share the backend name list. I will help you with the script.

 

Hi @Alka_Chaudhary

 

I would like to include the value from the short_description field of the dmn_requirement table in a notification  which I've created for the dmn_demand table. Below is my mail script.

 

(function runMailScript(current, template, email, email_action, event) {
var demand = new GlideRecord("dmn_requirement");
demand.addQuery("demand", current.sys_id)
demand.query() //if its for one record
if(demand.next()){
template.print(short_description.getDisplayValue());
}
})(current, template, email, email_action, event);