Check field value against reference field

Moedeb
Tera Guru

Hi,

 

I'm needing to do a check on a catalog item as it is being filled in. 

I have a text field called:

group_name 

 

What I want to do is after the field is filled in have it check the sys_user_group to see if a group name already exists that is the same.

 

I was thinking that I'd be able to do it via an onchange client script, but can't seem to get that to work.

Ultimately I want a message to come up advising that the name is already being used if it is found and to just let the person carry on if it is not found.

1 ACCEPTED SOLUTION

@Moedeb 

it means the value is not getting passed

Also I have updated the client script line as this

if(answer.toString() == 'true'){

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

View solution in original post

18 REPLIES 18

@Moedeb 

it means the value is not getting passed

Also I have updated the client script line as this

if(answer.toString() == 'true'){

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

@Ankur Bawiskar 

Ok that appears to be very close now.

When I add a new value that is not an active group it accepts it.

 

When I add an existing value it just blanks out the field - as in it clears the typed text

 

@Moedeb 

So I consider the script is working as expected

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

@Ankur Bawiskar 

 

Isn't this line meant to add a message so the user knows why the field is now blank? 

 

 

if(answer.toString() == 'true'){
			var message = 'This group is already present in groups table';
			g_form.clearValue('group_name'); 
			g_form.showFieldMsg('group_name ',message,'error', 
						true);