- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2023 01:28 AM
Hi!
I'm having a problem with getting the previous value of my 3 fields and put them on cc in 1 email.
We have 3 fields:
field name: supervisor_eid
field name: assignee_eid
field name: hr_eid
Everytime the user update these 3 fields simultaneously or update 2 fields simultaneously or just update only 1 field , there will be an email notification that will be sent to the New supervisor, New Assignee, and New HR . The previous supervisor , assignee and HR should be "CC" in the email.
Is there any way on how to add the previous assignee and previous hr on the cc using BR ? coz we cant get the previous values using email script only..
Business Rule:
Email Script:
Thank you in advance!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2023 01:51 AM
Hi @Dizy M ,
You can achieve by pushing to array access from email script to set in CC update script as per your requirement.
var supervisorValues = [];
var assigneeHrValues = [];
if (current.supervisor_eid != previous.supervisor_eid) {
supervisorValues.push(current.supervisor_eid);
supervisorValues.push(previous.supervisor_eid);
}
if (current.assignee_eid != previous.assignee_eid) {
assigneeHrValues.push(previous.assignee_eid);
}
if (current.hr_eid != previous.hr_eid) {
assigneeHrValues.push(previous.hr_eid); // Add previous HR
}
gs.eventQueue('email_cc_event', current, supervisorValues, assigneeHrValues);
Access in email script:
var emailList = [];
emailList = event.parm1;
if (!emailList.nil()) {
var emailAddr = emailList.split(",");
for (var i = 0; i < emailAddr.length; i++) {
email.addAddress("cc", emailAddr[i], "");
}
Do same for parm2
Please mark it as solution proposed and helpful if its serves your purpose.
Thanks,
Anand
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2023 01:48 AM
you can send all 3 previous and current values in JSON and then send it in parm1 or parm2
then in email script parse it and show the value of both previous and current
I shared solution for something similar for this earlier. just enhance it
Show previous assignmnet group, state values from fields into notification
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
11-08-2023 01:51 AM
Hi @Dizy M ,
You can achieve by pushing to array access from email script to set in CC update script as per your requirement.
var supervisorValues = [];
var assigneeHrValues = [];
if (current.supervisor_eid != previous.supervisor_eid) {
supervisorValues.push(current.supervisor_eid);
supervisorValues.push(previous.supervisor_eid);
}
if (current.assignee_eid != previous.assignee_eid) {
assigneeHrValues.push(previous.assignee_eid);
}
if (current.hr_eid != previous.hr_eid) {
assigneeHrValues.push(previous.hr_eid); // Add previous HR
}
gs.eventQueue('email_cc_event', current, supervisorValues, assigneeHrValues);
Access in email script:
var emailList = [];
emailList = event.parm1;
if (!emailList.nil()) {
var emailAddr = emailList.split(",");
for (var i = 0; i < emailAddr.length; i++) {
email.addAddress("cc", emailAddr[i], "");
}
Do same for parm2
Please mark it as solution proposed and helpful if its serves your purpose.
Thanks,
Anand