OnChange client script on reference field

Vijaykumar K
Tera Contributor

Hi all,

 

  • I'm looking for a request,  if "assigned to" is a some perticular user (reference to sys user table) then need to clear the value and revert back the changes on page. 

 

I'm trying the below script but it's not working as expected, it's working for every user not to specific to user sys Id. 

IMG_20231027_132801__01.jpg

1 ACCEPTED SOLUTION

ServiceNow Use6
Tera Guru

Hi @Vijaykumar K ,

You are using 'if' condition and you are using ';', so it is not entering the condition.

Regards

Suman P.

View solution in original post

11 REPLIES 11

ServiceNow Use6
Tera Guru

Hi @Vijaykumar K ,

You are using 'if' condition and you are using ';', so it is not entering the condition.

Regards

Suman P.

Thank you all for your usefull suggestions. 🙂

 

@ServiceNow Use6  that's what I'm looking for . Thank you 😊

Clara Lemos
Mega Sage
Mega Sage

Hi @Vijaykumar K ,

 

Try make the following changes  

var assign = g_form.getReference('assigned_to');
if(assign.sys_id =='your sys id');

A better approach tho would be to check the user's name: if(assign.name =='you user's name');

Let me know if that works ! 

Cheers!

Sandeep Rajput
Tera Patron
Tera Patron

@Vijaykumar K On line number 5 update your code as follows.

var assign = g_form.getValue('assigned_to');

Hello @Sandeep Rajput ,

 

I have already given answer same as your's.

Then why you are sending same again.

It will confuse readers.