How to set watchlist user based on account in case table
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-03-2025 02:27 AM
Hi Team,
I want to set watchlist user on case table, based Account then contact Relationships. In contact Relationships I have 3 contacts I need to all the three in watchlist field once they select that Account.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-03-2025 02:32 AM
so when case is created you can fetch the contact relationships using the account field on Case
what did you start with and where are you stuck?
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
03-03-2025 09:47 AM
(function executeRule(current, previous /*null when async*/) {
if (!current.account) {
return;
}
var watchlistUsers = [];
var gr = new GlideRecord('sn_customerservice_contact_relationship'); // Contact Relationships table
gr.addQuery('company', current.account);
while (gr.next()) {
if (gr.contact) {
watchlistUsers.push(gr.contact.toString());
}
}
if (watchlistUsers.length > 0) {
current.watch_list = watchlistUsers.join(','); // Update Watchlist field
}
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-03-2025 10:08 AM
Hi @sriram35 ,
the query statement is missing in the script
try this
(function executeRule(current, previous /*null when async*/ ) {
if (!current.account) {
return;
}
var watchlistUsers = [];
var gr = new GlideRecord('sn_customerservice_contact_relationship'); // Contact Relationships table
gr.addQuery('company', current.account);
gr.query();
while (gr.next()) {
if (gr.contact) {
watchlistUsers.push(gr.getValue('contact'));
}
}
if (watchlistUsers.length > 0) {
current.watch_list = watchlistUsers.join(','); // Update Watchlist field
}
})(current, previous);
Please mark my answer as helpful/correct if it resolves your query.
Regards,
Chaitanya
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-03-2025 06:53 PM
please add this line and see if it works
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