I want to restrict the Assign group based on COE for assigned to user

kumaar
Tera Contributor

So when the assigned to used comes to the case then he shout only see the groups based on coe

For example

If the Case is of hr benefits case and assignment group realted to this are D, A and C

Then he can only see these 3 groups to select.

I have written a Script include and Called it via Reference qualifier

My script is not working it seems

7 REPLIES 7

sunil maddheshi
Tera Guru

@kumaar , Can you copy and paste your code here, Below is one sample script you can use it in your case:

 getGroups: function(caseSysId) {
        var groups = [];
        if (!caseSysId) {
            gs.log("No caseSysId provided.");
            return groups; // Return empty if no caseSysId
        }

        // Get the Case record
        var caseGR = new GlideRecord('sn_hr_core_case');
        if (caseGR.get(caseSysId)) {
            var coe = caseGR.u_center_of_excellence; // Adjust field name if needed
            gs.log("COE for case: " + coe);

            // Get groups mapped to this COE
            var groupGR = new GlideRecord('sys_user_group');
            groupGR.addQuery('u_center_of_excellence', coe); // Ensure this field exists
            groupGR.query();

            while (groupGR.next()) {
                groups.push(groupGR.sys_id.toString());
            }

            gs.log("Valid Assignment Groups: " + groups.join(", "));
        } else {
            gs.log("No case found for sys_id: " + caseSysId);
        }

        return groups;
    },

Please mark correct/helpful if this helps you

var GetAllowedAssignmentGroups Class.create();

 

GetAllowedAssignmentGroups.prototype = {

 

initialize: function() (),

 

getGroups: function(coe) (

 

var groups [];

 

if (!assigned To) {

 

}

 

return ' ';

 

var coeGroups - {

 

'sn_hr_core_case_benefits': ['TMC_HR_Tier1', 'TMC_HR_TIER1_MANAGERS, TMC_EXEC_SUPPORT'],

 

'sn_hr_core_case_total_rewards': ['TMC_HR_Tier1", "TMC_HR_TIER1_MANAGERS, TMC_EXEC SUPPORT, TMC WELL_BEING_TIER3']

 

};

 

if (coe && coeGroups [coe]) {

 

groups coeGroups[coe];

 

}

 

var query nameIN + group.join(',');

 

return query;

 

type: "GetAllowedAssignmentGroups

 );

@kumaar 

Please try with below script:

var GetAllowedAssignmentGroups = Class.create();
GetAllowedAssignmentGroups.prototype = {
    initialize: function () {},

    getGroups: function (coe) {
        var groups = [];

        var coeGroups = {
            'sn_hr_core_case_benefits': ['TMC_HR_Tier1', 'TMC_HR_TIER1_MANAGERS', 'TMC_EXEC_SUPPORT'],
            'sn_hr_core_case_total_rewards': ['TMC_HR_Tier1', 'TMC_HR_TIER1_MANAGERS', 'TMC_EXEC_SUPPORT', 'TMC_WELL_BEING_TIER3']
        };

        if (coe && coeGroups[coe]) {
            groups = coeGroups[coe]; // Assign valid groups based on COE
        }

        if (groups.length > 0) {
            return 'nameIN' + groups.join(',');
        }

        return ''; // Return empty if no valid groups are found
    },

    type: "GetAllowedAssignmentGroups"
};

Please mark correct/helpful if this helps you!

And in the reference qualifier?