Slush bucket values based on assignment group

prashant8
Tera Expert

Hi everyone , thanks in advance .

When we change assignment group , show all group members in watch list (list collector type field).

Please provide suggestion 

@Ankur Bawiskar 

1 ACCEPTED SOLUTION

Saurav11
Kilo Patron
Kilo Patron

Hello,

 

Please use the below script:-

 

1) Write the below onchange client script of field assignment group:-

 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (isLoading || newValue === '') {
        return;
    }
    
        var ga = new GlideAjax('GetGrpmembers');
        ga.addParam('sysparm_name', 'GetGrp');
        ga.addParam('sysparm_group_name', g_form.getValue('assignment_group'));
        ga.getXML(HelloWorldParse);

        function HelloWorldParse(response) {
            var answer = response.responseXML.documentElement.getAttribute("answer");
            var fields = [];
            fields = JSON.parse(answer);
            for (i = 0; i < fields.length; i++) {
                g_form.setValue("watch_list", fields[i]);

            }
        }
    }

 

Then write a script include with the below script:-

 

var GetGrpmembers = Class.create();
var arr = [];
GetGrpmembers.prototype = Object.extendsObject(AbstractAjaxProcessor, {
	GetGrp: function() {
        var gr = new GlideRecord('sys_user_grmember');
        gr.addQuery('group', this.getParameter('sysparm_group_name'));
        gr.query();
        while (gr.next()) {
            arr.push(gr.user.toString());
        }
		var setMembers = JSON.stringify(arr);
        return setMembers;
	},
    type: 'GetGrpmembers'
});

 

Now once you have both the script as soon as you select assignment group all the members will be populated on watchlist .

 

Please mark my answer correct/helpful based on Impact.

View solution in original post

11 REPLIES 11

Astrid Sapphire
Tera Expert

Hey Prashant,

To confirm my understanding of your requirement, are you wanting to automatically populate the watch list with the group members? Or restrict the reference qualifier to only allow adding these users?

 

Either of the above would be possible - the former could get driven by a business rule or flow trigger. Restricting the reference qualifier for the slushbucket would be a little harder if you wanted to do it dynamically instead of setting it as standard, which you could do with a dictionary override for example.

Secondly, what outcome would this serve for you? Is this to ensure the assignment group members get notified appropriately? As that could happen through notifications.

 

Kind regards,


Astrid Sapphire

Hi , we have to show all members of selected assignment group in watch list

Arav
Tera Guru
Tera Guru

Hi,

 

You can use an onChange client script that makes an asynchronous call to a Script include function to get group members when group is changed. Alternatively, you could also use a Business Rule or Flow Designer to populate the field if you choose to do it at the server side.

 

But you may want to check the business requirement for this. Watch list usually contains users who would want to be informed or be part of an incident. So why would you want to add group members to watch list when they are already part of the assignment group and have visibility of the incident ?

 

Thanks,

Arav

Hi they asked me to this via script in interview, 

i tired but able to show only 1 user in watch list.

can you please provide code.