Assignment groups hidden for all groups expect a particular group

phr
Tera Contributor

Hi All,

 

I have a requirement and it says :

Suppose there is 

1) Group A

2) Group B

3) Group C, D, E...and so on

 

Whenever the user group Group B logs in and opens the incident form in the Assignment group Field Group B member should be able to see Group A.

For Groups C, D, E...and so on ...Group A should be hidden.

 

(No one should be able to assign incidents to Group A except Group B)

 

How to achieve this?

6 REPLIES 6

Mark Manders
Mega Patron

Create a script include (something like this):

var GroupVisibility = Class.create();
GroupVisibility.prototype = Object.extendsObject(AbstractAjaxProcessor, {
    getVisibleGroups: function() {
        var userGroups = gs.getUser().getMyGroups(); // Get the groups the user belongs to
        var visibleGroups = [];
        var groupSysIdB = 'sys_id_of_group_b'; // Replace with the actual sys_id of group 'b'
        var groupSysIdA = 'sys_id_of_group_a'; // Replace with the actual sys_id of group 'a'

        // Check if user is a member of group 'b'
        if (userGroups.indexOf(groupSysIdB) !== -1) {
            // Add group 'a' and all other groups
            visibleGroups.push(groupSysIdA);
        }

        // Add all other groups except 'a'
        var gr = new GlideRecord('sys_user_group');
        gr.addQuery('sys_id', '!=', groupSysIdA);
        gr.query();
        while (gr.next()) {
            visibleGroups.push(gr.sys_id.toString());
        }

        return visibleGroups.join(',');
    },

    type: 'GroupVisibility'
});

and an advanced reference qualifier like this:

answer = 'sys_idIN' + new GroupVisibility().getVisibleGroups();

Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark

phr
Tera Contributor

Hi @Mark Manders ,

Also could you please detail how to call script include in the business rule?

 

Thank you.

What business rule? You call it in an advanced reference qualifier on the field.


Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark

Hi @phr 

How to call Script Include from BR:

new MyScriptIncludeName().functionName();