OnLoad Client script to populate assigned to && assignment group

Alon Grod
Tera Expert

Hi,

 

I have the fields Assignment group and assigned to on incident table. I have a requirements to populate Assignment group as the 'caller' group and the assigned to as the caller.

How can I achieve that?

1 ACCEPTED SOLUTION

If you want to do it via OnLoad Client Script + Display BR then below code can help you

in Display BR

var caller = current.getValue('caller_id'); // mention proper column name of caller_id and it gives us the sys_id
	var gr = new GlideRecord('sys_user_grmember_list'); //navigating to group members and checking the user's groups
	gr.addQuery('user',caller); //As you have mentioned there will only be one caller to the group I'm going with if, else we need to use while
	gr.query();
	if(gr.next()){
		g_scratchpad.group = gr.group; //this will fetch you the sys_id of the group
	}

 

In Client Script

 if (g_scratchpad.group) {
            g_form.setValue('assignment_group', g_scratchpad.group);
g_form.setValue('assigned_to',g_form.getValue("caller_id")); //as you have mentinoed the assigned_To needs to be same as caller.
        }

       
Please hit like button if my suggestion has helped you in any way.
Please mark correct if my response has solved your query.

Cheers,
Mohammed Basheer Ahmed.

View solution in original post

9 REPLIES 9

Hi @Alon Grod ,

Follow these steps:

System Policy > Rules > Assignment 

Click New

Give it a name for example : Assigned_to and Assignment_group based on caller

Navigate to Applies to section and mention the table as incident and give the conditions as per your requirement

Navigate to Assign To section and mention your assigned_to and assignment_group things.

If you need any script to be written you can mention in the script section.

 

Please hit like button if my suggestion has helped you in any way.
Please mark correct if my response has solved your query.

Cheers,
Mohammed Basheer Ahmed.

If you want to do it via OnLoad Client Script + Display BR then below code can help you

in Display BR

var caller = current.getValue('caller_id'); // mention proper column name of caller_id and it gives us the sys_id
	var gr = new GlideRecord('sys_user_grmember_list'); //navigating to group members and checking the user's groups
	gr.addQuery('user',caller); //As you have mentioned there will only be one caller to the group I'm going with if, else we need to use while
	gr.query();
	if(gr.next()){
		g_scratchpad.group = gr.group; //this will fetch you the sys_id of the group
	}

 

In Client Script

 if (g_scratchpad.group) {
            g_form.setValue('assignment_group', g_scratchpad.group);
g_form.setValue('assigned_to',g_form.getValue("caller_id")); //as you have mentinoed the assigned_To needs to be same as caller.
        }

       
Please hit like button if my suggestion has helped you in any way.
Please mark correct if my response has solved your query.

Cheers,
Mohammed Basheer Ahmed.

@Basheer Always have the right answers! thank you!

 

Paul Curwen
Giga Sage

You will find the perfect solution to this in this community post: 

 

https://www.servicenow.com/community/itsm-forum/assignment-group-should-be-populate-based-on-caller-...

 

If helpful please mark as Helpful/Correct

***If Correct/Helpful please take time mark as Correct/Helpful. It is much appreciated.***

Regards

Paul

@Basheer can you please help me with the on load client script solution