- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-26-2022 08:15 AM
Hi ,
I have a requirement where there is a field of type list (Users Who Worked the Case)referenced to sys_user table .
There are 3 other fields refernced to sys_user table :Initial Assigned to,Assigned to ,# of Outreach Attempts Needed to Resolve
Whenever the Initial Assigned to changes
- IF the Initial Assigned to user is not already in the "Users Who Worked the Case" list field, then automatically add the Initial Assigned to user to the list.
Whenever the Assigned to changes
- IF the Assigned to user is not already in the "Users Who Worked the Case" list field, then automatically add the Assigned to user to the list.
Whenever an agent changes the "# of Outreach Attempts Needed to Resolve" dropdown value:
- IF the current user is not already in the "Users Who Worked the Case" list field, then automatically add the Assigned to user to the list.
kindly help me with the solution.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-29-2022 05:36 AM
Hi,
Try below script,
BR Condition : Initial Assigned to changes OR Assigned to changes OR Outreach Attempts Needed to Resolve changes
Script :
(function executeRule(current, previous /*null when async*/ ) {
// Add your code here
var inas = current.u_initial_assigned_to_ris;
var assign_to = current.assigned_to;
var outreach = gs.getUserID();
var users = current.users_who_worked_the_case.split(',');
if(current.u_initial_assigned_to_ris.changes() && current.users_who_worked_the_case.toString().indexOf(inas)==-1){
if(current.users_who_worked_the_case){
current.users_who_worked_the_case+=","+inas;
}else{
current.users_who_worked_the_case=inas;
}
}
if(current.assigned_to.changes() && current.users_who_worked_the_case.toString().indexOf(assign_to)==-1){
if(current.users_who_worked_the_case){
current.users_who_worked_the_case+=","+assign_to ;
}else{
current.users_who_worked_the_case=assign_to ;
}
}
if(current.outreach_needed_to_resolve.changes() && current.users_who_worked_the_case.toString().indexOf(outreach)==-1){// change field name 'outreach_needed_to_resolve' with actual field name
if(current.users_who_worked_the_case){
current.users_who_worked_the_case+=","+outreach;
}else{
current.users_who_worked_the_case=outreach;
}
}
})(current, previous);
Please mark this as Correct or Helpful if it helps.
Regards,
Abhijit
Community Rising Star 2022
Regards,
Abhijit
ServiceNow MVP

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-26-2022 10:49 AM
Hello,
Please share more from your side such as what you've done, what you've tried, etc.
So far, you've only posted your requirement with nothing else from your side.
Please mark reply as Helpful, if applicable. Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-29-2022 04:17 AM
hi ,
I have tried before insert,update business rule with below script :
(function executeRule(current, previous /*null when async*/ ) {
// Add your code here
var inas = current.getDisplayValue('u_initial_assigned_to_ris');
var assign_to = current.getDisplayValue('assigned_to');
var outreach = gs.getUserID();
var users = current.users_who_worked_the_case.split(',');
if (current.inas != users) {
users.push(current.u_initial_assigned_to_ris.toString());
users = new ArrayUtil().unique(users);
current.users_who_worked_the_case = users.toString();
} else if (current.assign_to != users) {
// var users = current.users_who_worked_the_case.split(',');
users.push(current.assign_to.toString());
users = new ArrayUtil().unique(users);
current.users_who_worked_the_case = users.toString();
}
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-29-2022 04:51 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-29-2022 05:36 AM
Hi,
Try below script,
BR Condition : Initial Assigned to changes OR Assigned to changes OR Outreach Attempts Needed to Resolve changes
Script :
(function executeRule(current, previous /*null when async*/ ) {
// Add your code here
var inas = current.u_initial_assigned_to_ris;
var assign_to = current.assigned_to;
var outreach = gs.getUserID();
var users = current.users_who_worked_the_case.split(',');
if(current.u_initial_assigned_to_ris.changes() && current.users_who_worked_the_case.toString().indexOf(inas)==-1){
if(current.users_who_worked_the_case){
current.users_who_worked_the_case+=","+inas;
}else{
current.users_who_worked_the_case=inas;
}
}
if(current.assigned_to.changes() && current.users_who_worked_the_case.toString().indexOf(assign_to)==-1){
if(current.users_who_worked_the_case){
current.users_who_worked_the_case+=","+assign_to ;
}else{
current.users_who_worked_the_case=assign_to ;
}
}
if(current.outreach_needed_to_resolve.changes() && current.users_who_worked_the_case.toString().indexOf(outreach)==-1){// change field name 'outreach_needed_to_resolve' with actual field name
if(current.users_who_worked_the_case){
current.users_who_worked_the_case+=","+outreach;
}else{
current.users_who_worked_the_case=outreach;
}
}
})(current, previous);
Please mark this as Correct or Helpful if it helps.
Regards,
Abhijit
Community Rising Star 2022
Regards,
Abhijit
ServiceNow MVP