- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-25-2023 06:28 AM
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
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-25-2023 02:42 PM - edited 10-25-2023 02:43 PM
@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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-25-2023 02:33 PM
So looks like you Already have the mail script. You can just add some label to it as below
template.print('DMN Requirement: '+short_description.getDisplayValue());
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-25-2023 02:42 PM - edited 10-25-2023 02:43 PM
@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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-26-2023 06:22 AM - edited 10-26-2023 06:26 AM
You forgot the GR variable infront.
short_description.getDisplayValue() doesn't work, because it's not point to anything.
Also if it's only one record, do not forget the set limit
(function runMailScript(current, template, email, email_action, event) {
var grDemand = new GlideRecord("dmn_requirement");
grDemand.addQuery("demand", current.getUniqueValue())
grDemand.setLimit(1);
grDemand.query() //if its for one record
if(grDemand.next()){
template.print(grDemand.short_description);
}
})(current, template, email, email_action, event);
OR (even shorter)
(function runMailScript(current, template, email, email_action, event) {
var grDemand = new GlideRecord("dmn_requirement");
if(grDemand.get("demand", current.getUniqueValue())) {
template.print(grDemand.short_description);
}
})(current, template, email, email_action, event);
Hope that helps