i want to update an existing watchlist to include a new user for all new incidents.

Wayne DeCoste
Tera Contributor

Hello.

We have a new user on the support team. How do I update an existing watchlist with this new user so he is notified when a new incident is created, or an existing incident is updated/closed? 

Is there a way to do this without running a script? 

 

Thanks!

1 ACCEPTED SOLUTION

That's great @Wayne DeCoste ,

 

Can you please mark the solution as accepted/helpful so that it helps future readers.

That will be much appreciated 🤗!

If this works, please mark it as helpful/accepted — it keeps me motivated and helps others find solutions.
Shashank Jain

View solution in original post

19 REPLIES 19

Wayne DeCoste
Tera Contributor

Hello again.
Thanks for the update. What I am trying to do, is add a new team member to the incident watch list for all new incidents. So this likely wont do that? 

@Wayne DeCoste , You can create business rule for that if you want to update on newly created incidents.

 

If this works, please mark it as helpful/accepted — it keeps me motivated and helps others find solutions.
Shashank Jain

@Wayne DeCoste ,

 

Refer this for creating the business rule , it will update the newly created incident.

Screenshot (28).png

 

In the advanced condition add this code.

 

(function executeRule(current, previous /*null when async*/) {

    var userToAdd = 'a8f98bb0eb32010045e1a5115206fe3a'; // Give the sys id of user you wanted to add.
    var currentWatchlist = current.getValue('watch_list') || '';  
    var watchlistArray = currentWatchlist.split(',').filter(Boolean); 

    if (watchlistArray.indexOf(userToAdd) == -1) {  
        watchlistArray.push(userToAdd);
        current.setValue('watch_list', watchlistArray.join(','));
        current.update();
    } else {
        gs.print(gr.number + " already had the user in watchlist");
    }
})(current, previous);

 

Note - It will add the user to the newly created incident watchlist after saving the record.

 

If this works, please mark it as helpful/accepted — it keeps me motivated and helps others find solutions.
Shashank Jain

RaghavSh
Kilo Patron

This will need scripting:

 

For old incidents:

var inc = new GlideRecord('incident'); // You can add query if yiu want to update a subset of incidents
inc.query();
while(inc.next())
{
inc.watchlist = inc.watchlist  + ',' + 'sys_id of new user';   // verify and update the watchlist backend name
inc.update();
}

 

For new incidents: Create a before insert BR on incident table with below code:

 

current.watchlist = current.watchlist + ',' +'sys_id of new user'; // update watchlist backend name and sys_id value as per your req

Raghav
MVP 2023

Wayne DeCoste
Tera Contributor

Hello, thanks!

I found the system property hiaa.decisions.incidet_watch_list. In there I see the sys_id of the decision table it is pointing to. 

Im trying to open the decision table using the URL: https://<your-instance>.service-now.com/sn_dt_decision_table.do?sys_id=<sys_id>. Replacing the instance and sys_id of the decision table. My thought is that I can add the sys_id of the user there. 

But, I cant seem to open the decision table. Maybe my approach using the URL is not the right one to access the decision table?