How to add certain fields in the email script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2024 02:17 AM
Hi Team,
How to add certain fields in the email script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2024 02:19 AM
search the email script and add your fields.
what's the challenge?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2024 02:30 AM
use template.print(current.fieldname.getDisplayValue());
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2024 03:07 AM - edited 06-11-2024 03:14 AM
Hello @Gopal14
Refer below screenshot here I expanded the caller field and clicked on the active field to get it.
Caller Active: ${caller_id.active} it will populate automatically.
If you have specific conditions to get the value then You can try below email script to get the required value
(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */
email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */
event) {
var ab = new GlideRecord('table_name');
// ab.addEncodedQuery('add your encoded query here if you have any');
//ab.addQuery('parent',sys_id); // you can add the reference fileds if it has paent child relationship.ex: //parent, current sysid;
ab.query();
while (ab.next()) {
template.print(ab.field_name); //use this if the target field is string
template.print(ab.getDisplayValue('field_name')); //use this if the target field is reference field
}
})(current, template, email, email_action, event);
If my answer is helpful please mark it as helpful or correct!!
Pratima.k