Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to get the assignment group type in client script?

Snehal2
Kilo Guru

Hi Developers,

 I need to make a field(s_comments) visible on incident only if the Assignment group type="Supplier".

For this, I have written a UI policy on s_comments to hide it and a client script to control its visibility if the Assignment group type="Supplier". but its not working.

In client script I used the call back reference. Can any one let me know how can this be done?

 

Thanks in advance.

 

 

1 ACCEPTED SOLUTION

Raju Koyagura
Tera Guru

Instead of client script, better dot walk Assignment Group to get the type in UI Policy condition builder something like below 

 

find_real_file.png

View solution in original post

3 REPLIES 3

Raju Koyagura
Tera Guru

Instead of client script, better dot walk Assignment Group to get the type in UI Policy condition builder something like below 

 

find_real_file.png

Hi Raju,

Its working as expected. Thanks a lot. It was simple but I was trying tough one.

But I m not getting why the tough one is not working..It was something as below. I tried(hardcoded) using sysID of group type Supplier but that was also not working...

Can u let me know whats wrong in below script:

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
	if (newValue === '') {
		return;
	}
		
	var grp = g_form.getReference('assignment_group',doAlert);

//alert(grp.type.getDisplayValue());

	 function doAlert(grp) { //reference is passed into callback as first arguments

//alert(grp.type.getDisplayValue());

		if(grp.type == 'Supplier')
 			{
//alert('Supplier'+grp.type);
 		  g_form.setVisible('u_s_comments', true);
 			}
	}
}

Varsha21
Giga Guru
Hi Snehal ,
           
    in your client script you trying to refer assignment_group's type
 
1.you will get easily group by using getReference() method, which is field of sys_user_group table,
2.and you are trying to fetch the type of group..but in this case  group type field is type of glide_list (generally it contains list of references)
 
 
for glide_list refer the link
 
 
 
if useful hit like or mark correct!!
 
 
Regards,
 
Varsha