Assignment Group should be populate based on Caller Group

Vamsi26
Tera Contributor

Hello Everyone,

I am having requirement as if the Caller user is a member of "SNOW-L1-USERS" group then the incident should be automatically assigned to "SNOW-L2-USERS" group.

Can you please help me how can i achieve this.

 

Thanks 🙂

1 ACCEPTED SOLUTION

shloke04
Kilo Patron

Hi,

Please follow the steps below to achieve your requirement:

Below is a tested method and works correctly in my PDI for both on Change and On Load of your Caller value on Incident or any other form you want.

1) Create a Display Business Rule on your Table where the caller field is present , I am considering it is present on Incident table. So, below need to be implemented:

BR:

Type: Display

Table: Incident:

Script:

(function executeRule(current, previous /*null when async*/) {

	// Add your code here
	var getCaller = current.getValue('caller_id'); // Replace "caller_id" with your caller field
	var gr = new GlideRecord('sys_user_grmember_list');
	gr.addQuery('user',getCaller);
	gr.addQuery('group','groupSYSID here'); // pass the Sys id of group "SNOW-L1-USERS"
	gr.query();
	if(gr.next()){
		g_scratchpad.isMember = true;
	}else{
		g_scratchpad.isMember = false;
	}

})(current, previous);

find_real_file.png

 

Now write an On Change Client Script on Incident Table and use the script as below:

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (isLoading || newValue === '') {
        if (g_scratchpad.isMember == true) {
            g_form.setValue('assignment_group', g_scratchpad.GroupID);
        }

        return;
    }
    if (newValue && g_scratchpad.isMember == true) {
        g_form.setValue('assignment_group', g_scratchpad.GroupID);
    }

    //Type appropriate comment here, and begin script below

}

find_real_file.png

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

View solution in original post

8 REPLIES 8

Anmol8
Mega Guru

Hello,

1. You have to write the script include non client callable and write script so that it fetches user from that particular group. 

2. Add reference qualifier on the user field. for example - javascript:new myScriptInclude().my_refqual().

Please refer the code to get the users from groups.

Now for the new incident.

1. Create a business rule .

2. Which runs on condition if the user is memberof that group, you can create new record on incident table and set the assignment group field with the required sysid of group you need.

Thanks

Please mark helpful and correct if applicable.

getGroupUsers : function(groupId)
	{
		var usersArr = [];
		
		var groupMembers = new GlideRecord('sys_user_grmember');
		if(groupId !='')
		groupMembers.addQuery('group',groupId);
		groupMembers.query();
		while(groupMembers.next())
		{
			usersArr.push(groupMembers.user.sys_id.toString());
		}
		return 'sys_idIN' + usersArr.toString();

	},

shloke04
Kilo Patron

Hi,

Please follow the steps below to achieve your requirement:

Below is a tested method and works correctly in my PDI for both on Change and On Load of your Caller value on Incident or any other form you want.

1) Create a Display Business Rule on your Table where the caller field is present , I am considering it is present on Incident table. So, below need to be implemented:

BR:

Type: Display

Table: Incident:

Script:

(function executeRule(current, previous /*null when async*/) {

	// Add your code here
	var getCaller = current.getValue('caller_id'); // Replace "caller_id" with your caller field
	var gr = new GlideRecord('sys_user_grmember_list');
	gr.addQuery('user',getCaller);
	gr.addQuery('group','groupSYSID here'); // pass the Sys id of group "SNOW-L1-USERS"
	gr.query();
	if(gr.next()){
		g_scratchpad.isMember = true;
	}else{
		g_scratchpad.isMember = false;
	}

})(current, previous);

find_real_file.png

 

Now write an On Change Client Script on Incident Table and use the script as below:

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (isLoading || newValue === '') {
        if (g_scratchpad.isMember == true) {
            g_form.setValue('assignment_group', g_scratchpad.GroupID);
        }

        return;
    }
    if (newValue && g_scratchpad.isMember == true) {
        g_form.setValue('assignment_group', g_scratchpad.GroupID);
    }

    //Type appropriate comment here, and begin script below

}

find_real_file.png

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

shloke04
Kilo Patron

Hi Vamsi,

If your query is resolved, can you please mark the answer as correct and close this thread for others.

Regards,

Shloke

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

adnanhaider
Tera Contributor

Why Caller ID show more User then Assignment to?