- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2025 03:13 AM
Hi
I have requirement like whoever changing the field called state(field is on sc_req_item table) as pending then notification should trigger with that state field upated by name in the body of the notification(on sc_req_item). How can I get this one
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2025 04:42 AM
you will have to use email script for that. I hope you know how to do that or can search in docs for the same
1) create email script -> get_user
2) then include that in email body of your notification like this and print the content
${mail_script:get_user}
(function runMailScript(current, template, email, email_action, event) {
// Add your code here
var gr = new GlideRecord("sys_user");
gr.addQuery("user_name", current.sys_updated_by);
gr.query();
if (gr.next()) {
template.print("State pending Updated By : " + gr.getDisplayValue());
}
})(current, template, email, email_action, event);
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
01-23-2025 03:39 AM
you can use this in email body if the notification is on RITM table
State pending Updated By : ${sys_updated_by}
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
01-23-2025 04:29 AM
Hi @Ankur Bawiskar Thanks alot it's working fine but need one last change now am getting the userid but how to get the full user name ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2025 04:42 AM
you will have to use email script for that. I hope you know how to do that or can search in docs for the same
1) create email script -> get_user
2) then include that in email body of your notification like this and print the content
${mail_script:get_user}
(function runMailScript(current, template, email, email_action, event) {
// Add your code here
var gr = new GlideRecord("sys_user");
gr.addQuery("user_name", current.sys_updated_by);
gr.query();
if (gr.next()) {
template.print("State pending Updated By : " + gr.getDisplayValue());
}
})(current, template, email, email_action, event);
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
01-23-2025 03:21 AM - edited 01-23-2025 03:22 AM
hi @raj99918
You can use flow designer as suggested by Ankur or use business rule to trigger the email notification:
- Create a Business Rule on table sc_req_item to Detect the Change in the State Field
- Condition state changes to "Pending"
- Call notification from the BR script
I hope my answer helps you to resolve your issue, if yes please mark my answer helpful and correct.
thank you
Rajesh