- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-15-2022 07:07 PM
Hello,
I'm trying to add a mail script to my email notification but need help with the script.
My email notification is on the "sn_vdr_risk_asmt_vdr_tiering_assessment" table.
I need help with the mail script to get the value from the field "TPRM-01.01" and ADD it on to my email notification.
This field "TPRM-01.01" (u_ucla_ociso_tprm_triage_tprm_01_01) is on the "sn_vdr_risk_asmt_ucla_ociso_tprm_triage" table.
Please kindly help me with the mail script. Thank you.
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-16-2022 08:05 AM
Hi,
It is working based on your query that you provided because you are not giving any condition and using while Loop so will return all the values. If you need single value use If Loop.
Please add condition grrisk.addQuery(); then it will display the data.
You need to filter the data. Then Use like below
template.print("TPRM-01:01"+grrisk.getDisplayValue('u_ucla_ociso_tprm_triage_tprm_01_01'));
Hope you understood it!!
If it Please Mark ✅ Correct/Helpful, Thanks!!
Regards
Pavankumar
ServiceNow Community MVP 2024.
Thanks,
Pavankumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-15-2022 07:28 PM
Hi,
You can access the all fields of [sn_vdr_risk_asmt_vdr_tiering_assessment] table using current object in email scripts.
For example-
if it is reference field - currect.u_ucla_ociso_tprm_triage_tprm_01_01.getDisplayValue();
if it is String field - currect.u_ucla_ociso_tprm_triage_tprm_01_01.toString();
Feel free to mark helpful & correct!
Thanks,
Sagar Pagar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-15-2022 07:55 PM
Hi,
If form has a field with reference table of sn_vdr_risk_asmt_ucla_ociso_tprm_triage you can get it without code. Expand the reference field and click on the field which need.
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 and give conditions on addQuery if it has any relation.
(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */
email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */
event) {
var grrisk = new GlideRecord('sn_vdr_risk_asmt_ucla_ociso_tprm_triage');
// grrisk.addEncodedQuery('add your encoded query here if you have any');
//grrisk.addQuery('parent',sys_id); // you can add the reference fileds if it has paent child relationship.ex: //parent, current sysid;
grrisk.query();
while (grrisk.next()) {
template.print(grrisk.u_ucla_ociso_tprm_triage_tprm_01_01); //use this if the target field is string
template.print(grrisk.getDisplayValue('u_ucla_ociso_tprm_triage_tprm_01_01')); //use this if the target field is reference field
}
})(current, template, email, email_action, event);
Hope it helps!!
If it Please Mark ✅ Correct/Helpful, Thanks!!
Regards
Pavankumar
ServiceNow Community MVP 2024.
Thanks,
Pavankumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-16-2022 07:16 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-16-2022 08:05 AM
Hi,
It is working based on your query that you provided because you are not giving any condition and using while Loop so will return all the values. If you need single value use If Loop.
Please add condition grrisk.addQuery(); then it will display the data.
You need to filter the data. Then Use like below
template.print("TPRM-01:01"+grrisk.getDisplayValue('u_ucla_ociso_tprm_triage_tprm_01_01'));
Hope you understood it!!
If it Please Mark ✅ Correct/Helpful, Thanks!!
Regards
Pavankumar
ServiceNow Community MVP 2024.
Thanks,
Pavankumar
