- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-23-2024 12:30 AM - edited ‎08-23-2024 04:01 AM
Hi Servicenow Experts,
I have a requirement for my cmdb table...When 4 fields on the form has been changed they want to send notification to a group with the old and new value of that field that has been changed on the record.
For this i created a event, there BR after update on cmdb table here is the BR script...not sure what to put in eventqueue syntax is correct? Also after this need to create email script so need help on that as i am not getting what to code in email script to get that data to create notification. Can someone please help me on this req it would be great help. Thanks @Ankur Bawiskar @sohail_mohamad @HrishabhKumar @Sandeep Rajput @Anil Lande
Attaching br so far what i have done:-
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-23-2024 05:57 AM
try this
I have used .toString() whenever you are getting the value from current and previous object
Also note support_group is reference so it will give sysId so if you want to show group name then use getDisplayValue()
Same goes with install_status which is a choice type; if you simply get the value you will get choice value and not choice label; so I used getDisplayValue() there as well
var arr = [];
if (current.name.changes()) {
var temp1 = {};
temp1['field'] = 'name';
temp1['oldvalue'] = previous.name.toString();
temp1['newvalue'] = current.name.toString();
arr.push(temp1);
}
if (current.install_status.changes()) {
var temp2 = {};
temp2['field'] = 'install_status';
temp2['oldvalue'] = previous.install_status.getDisplayValue();
temp2['newvalue'] = current.install_status.getDisplayValue();
arr.push(temp2);
}
if (current.support_group.changes()) {
var temp3 = {};
temp3['field'] = 'support_group';
temp3['oldvalue'] = previous.support_group.getDisplayValue();
temp3['newvalue'] = current.support_group.getDisplayValue();
arr.push(temp3);
}
if (current.u_sla_definition.changes()) {
var temp4 = {};
temp4['field'] = 'u_sla_definition';
temp4['oldvalue'] = previous.u_sla_definition.toString();
temp4['newvalue'] = current.u_sla_definition.toString();
arr.push(temp4);
}
gs.eventQueue('ba.notification.group', current, JSON.stringify(arr));
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
‎08-23-2024 05:49 AM - edited ‎08-23-2024 05:49 AM
@Ankur Bawiskar I tried using event.parm1 instead of event.parm2 in email script and this is what i am getting in notification body:-
Field: install_status Old Value: [object Object] New Value: [object Object]
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-23-2024 05:57 AM
try this
I have used .toString() whenever you are getting the value from current and previous object
Also note support_group is reference so it will give sysId so if you want to show group name then use getDisplayValue()
Same goes with install_status which is a choice type; if you simply get the value you will get choice value and not choice label; so I used getDisplayValue() there as well
var arr = [];
if (current.name.changes()) {
var temp1 = {};
temp1['field'] = 'name';
temp1['oldvalue'] = previous.name.toString();
temp1['newvalue'] = current.name.toString();
arr.push(temp1);
}
if (current.install_status.changes()) {
var temp2 = {};
temp2['field'] = 'install_status';
temp2['oldvalue'] = previous.install_status.getDisplayValue();
temp2['newvalue'] = current.install_status.getDisplayValue();
arr.push(temp2);
}
if (current.support_group.changes()) {
var temp3 = {};
temp3['field'] = 'support_group';
temp3['oldvalue'] = previous.support_group.getDisplayValue();
temp3['newvalue'] = current.support_group.getDisplayValue();
arr.push(temp3);
}
if (current.u_sla_definition.changes()) {
var temp4 = {};
temp4['field'] = 'u_sla_definition';
temp4['oldvalue'] = previous.u_sla_definition.toString();
temp4['newvalue'] = current.u_sla_definition.toString();
arr.push(temp4);
}
gs.eventQueue('ba.notification.group', current, JSON.stringify(arr));
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
‎08-23-2024 06:05 AM
TYSM it worked