Restrict assignment groups based on account on case record.

Anwar2
Tera Contributor

Hi Team,

 

I need to restrict the assignment group field on case record.

Scenario is we need to check the account record from case record where field called Customer Owned is true on account,Than we have to only show the assignment group from refrence field "Customer Owned" or

we need to check the account record from case record where field called Partner Owned is true on account,Than we have to only show the assignment group from refrence field "Partner Owned".

If both of them are are not checked on Account than have to show all the assignment groups in assignment refrence field on case.

 

I have alredy write the code but its not working can someone help me what I am missing.

 

I am using script include and calling it in dictionary override of assignment group field.

 

Refrence Qualifier : javascript: new AccountByPartnerOrCustomer().getGroups(current.account.u_partner_owned,current.account.u_customer_owned);

 

Below is script include:

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

    getGroups: function(partner, customer) {

		var partnerAcc = account.u_partner_owned=true;
		var customerAcc = account.u_customer_owned=true;

		var custAccount = new GlideRecord('customer_account');
		custAccount.addQuery('name',account);
		custAccount.query();
		
        var arr = [];
        if (partnerAcc) {
            var grpPartner = new GlideRecord('sys_user_group');
            grpPartner.addQuery('name', 'Partner Owned');
            grpPartner.query();
            if (grpPartner.next()) {
                arr.push(grpPartner.getValue('name'));
            }

        } else if (customerAcc) {
            var grpCustomer = new GlideRecord('sys_user_group');
            grpCustomer.addQuery('name', 'Customer Owned');
            grpCustomer.query();
			gs.info('customer owned');
            if (grpCustomer.next()) {
                arr.push(grpCustomer.getValue('name'));
            }

        } else {
            var grpAll = new GlideRecord('sys_user_group');
            grpAll.addActiveQuery();
            grpAll.query();
            while (grpAll.next()) {
                arr.push(grpAll.getValue('name'));
            }

        }
        return 'nameIN' + arr;
    },

    type: 'AccountByPartnerOrCustomer'
};

 

Thanks,

Anwar

3 REPLIES 3

Ankur Bawiskar
Tera Patron
Tera Patron

@Anwar2 

what debugging have you done so far?

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi Ankur,

 

Its showing me only the first function for 'u_partner_owned' assignment group its not showing for customer owned might be my reference qulifier is wrong.

 

Could you please guide me on this.

 

Thanks,

Anwar

Anwar2
Tera Contributor

Thanks Guys I got solution my self by just passing the sys_id's of groups.