
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2023 05:14 AM
I want to send a notification with the old value and new value (from sys_history_line table) when the company name changes on core_company table.
Notification Subject should be like below.
Company name changed from 'Old Company Name' to 'New Company Name'.
How to get the old value on the notification subject/body?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2023 07:25 AM
@Community Alums
why to use sys_history_line table?
you can use eventQueue based approach and send the old and new value
1) create event on that table
2) use after update BR on core_company table Name Changes to trigger the event
3) use script to trigger event and include the old and new value in event parameter
4) then use email script to print the old and new value
5) include the email script in email body. I hope you are aware on how to do this
(function executeRule(current, previous /*null when async*/) {
// Add your code here
gs.eventQueue('event_name', current, gs.getUserID(), current.name + '||' + previous.name);
})(current, previous);
Email script:
(function runMailScript(current, template, email, email_action, event) {
// Add your code here
var val = event.parm2.toString();
var newValue = val.split('||')[0];
var oldValue = val.split('||')[1];
template.print('Company name changed from ' + oldValue + 'to ' + newValue);
})(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
07-11-2023 05:24 AM
You need to use Script Include for that.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2023 06:21 AM
Hi @Samaksh Wani , Could you help with that please.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2023 06:35 AM
Write a Client Script :-
var gr = new GlideRecord('table_name');
var comp = current.company;
var ga = new GlideAjax('Script_include_name');
ga.addParam('sysparm_name', 'script_include_function_name');
ga.addParam('sysparam_assignedTo', comp);
Script Include :-
var Script_include_name = Class.create();
Script_include_name.prototype = Object.extendsObject(AbstractAjaxProcessor, {
script_include_function_name: function() {
var comp = this.getParameter("sysparam_assignedTo")
return comp;
},
type: 'Script_include_name'
});
You can Call this Script include and get the variable there.
Plz mark my SOlution as Accept, If you find it helpful.
Regards,
Samaksh

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2023 08:56 AM
For which one