Need to auto populate director field when a assignment group is selected on an Incident ticket

jbark17
Tera Contributor

I have a requirement from a team that they want the Director field on an Incident ticket to auto populate when a certain assignment group is selected. The Director field is a reference field on the incident table, and the assignment group is also a reference field on the same table. I'm sure a business rule will suffice. Just need help with constructing the correct code. Thanks!

3 REPLIES 3

Brad Bowman
Kilo Patron
Kilo Patron

If the requirement is to see the Director field populated on the screen when the Assignment group is selected, then you'll want to use an onChange Client Script.  If Director does not need to be populated right when the Assignment group is selected, then a Business Rule is a better option since it covers all of the different ways an Assignment group could be selected (API, record view, list view, workflow,...).  The bigger question is how is Director related to Assignment group?  Do you have a custom field to your group table to hold the Director or is some other logic involved? 

Bert_c1
Kilo Patron

Hi,

 

You will need to post what table does the Director field reference. Is it 'sys_user'?  And then what field on sys_user_group matches. Is it the 'manager' field?  And which assignment groups do you want to do this with? With that, specific script logic can be provided.

 

A BR can work, with Conditions "Assignment group", Changes" AND

"Assignment group", "is", "group1" OR

"Assignment group", "is" group2" OR

...

Script logic may be:

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

	// Add your code here
	var sug = new GlideRecord('sys_user_group');
	sug.addQuery('sys_id', current.assignment_group.toString());
	sug.query();
	if (sug.next()) {
		current.u_director = sug.manager;
		gs.info("SetDirectorField: u_director = " + current.u_director);
	}

})(current, previous);

Deepak89
Tera Expert

Hello @jbark17 ,

Make it simple .

 

create a UI Policy with conditions assignment group in not ABC, then create a UI Action and Hide fields which you want to show.

 

if it work , marked it correct