autopopulate assignment group member into the watchlist

edwardwong
Tera Contributor

I need to auto populate the watchlist with the assignment group that have been selected on an incident form and it change in real time. so if it in hard the watchlist will have all the group member, when it in software, the watchlist should be change to the software group member, when it blank the watchlist should also be blank. How do i get a group on the watchlist when you can only pick on the user table?

1 ACCEPTED SOLUTION

Hi @edwardwong ,

In that case use below client script and script include:-

Client Script Onchange of assignment group:-

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (isLoading || newValue === '') {
        return;
    }

    //Populate Support group from Service Offering
	g_form.setValue('watch_list','');
    var assignmentGroup = new GlideAjax('getUsersWatchList'); //test is script include
    assignmentGroup.addParam('sysparm_name', 'getWatchList');
    assignmentGroup.addParam('sysparm_group', newValue);
    assignmentGroup.getXML(setWatchList);

    function setWatchList(response) {
        var group = response.responseXML.documentElement.getAttribute('answer');
	
		g_form.setValue('watch_list',group);

    }

}

 

Script include Client Callable :-

var getUsersWatchList = Class.create();
getUsersWatchList.prototype = Object.extendsObject(AbstractAjaxProcessor, {

    getWatchList: function() {
        var grArr = [];
        var assignmentGroup = this.getParameter('sysparm_group');
        var grpMembers = new GlideRecord("sys_user_grmember");
        grpMembers.addQuery("group", assignmentGroup);
        grpMembers.query();
        while (grpMembers.next()) {
            grArr.push(grpMembers.getValue('user'));
        }
       return grArr.toString();
    },

    type: 'getUsersWatchList'
});

 

GunjanKiratkar_0-1670836304883.png

GunjanKiratkar_1-1670836338295.png

 

 


Please Mark My Response as Correct/Helpful based on Impact
Regards,
Gunjan Kiratkar
2X ServiceNow MVP
Community Rising Star 2022
Youtube : ServiceNow Guy

View solution in original post

9 REPLIES 9

I trying to see why it not working and, i been getting this [PA AppSec] Daily Data Collection completed with error. Why is this happening?

member name not seen in watchlist on sys_id of member get

only reflect sys_id of user i want name of that user how can achive

Tony Chatfield1
Kilo Patron

Hi, can you clarify the business requirement\driver for this?
Why must member of the task assignment group be visible in the watch list?


Watchlist members would not normally get updates to task work_notes,

and assignment group members would normally receive notifications based on notification 'Users/groups in fields'

like these OOB examples

/sysevent_email_action_list.do?sysparm_query=active%3Dtrue%5Erecipient_fields%3Dassignment_group&sysparm_view=

 

This seems like an unnecessary customization, what are you trying to achieve?
You would also have issues removing users if the assignment group changed, as there is no OOB way to identify if a group member pre-existed in the watch list before it was updated with the current assignment group members.

SuhasPSalunkhe
Kilo Guru

You can add users from group to watchlist.

You have to extract users from group and add into watchlist.

 

You cannot set watchlist value as group and it will take all users automatically