Field on record producer populating based on the another field on the form

Simran321
Tera Expert

Hi there,

 

I have a field on the form "Employee Leaving". I want to populate another field "Who should the direct report be assigned to" if this Employee Leaving is a manager. Can someone help with the client script and script include.

 

Basically, we need to check if the user selected on the employee leaving field is a manager of any other user and if he is then populate the field ""Who should the direct report be assigned to"  else don't populate the field on the form

 

Thanks

6 REPLIES 6

Ankur Bawiskar
Tera Patron
Tera Patron

@Simran321 

you can use onChange client script + GlideAjax to check if the selected user is manager and not

What did you start with?

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

Simran321
Tera Expert

@Ankur Bawiskar  This is what I have so far but it is not working

 

Simran321_1-1691689951596.png

 

 

Simran321_2-1691690064737.png

 

 

 

@Simran321 

Did you check what came in alert for the response?

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

Riya Verma
Kilo Sage

Hi @Simran321 ,


Hope you are doing great. 

 

I have gone through your script, script include will be returning boollean value as true or false from function as hasNext() Function return boolean value. If your logic is returning correct value then try to use below modification in client script code :

  • In callback function defines , where you are checking the condition response == 'false' is incorrect as per me as you are trying to compare the boolean value with string value as "false".  Try to use  below part while comparing repsponse ;

 

if (response == false ){
//logic - set value to true
}
else{

//logic -  set value to false

}​

 

 
Please mark the appropriate response as correct answer and helpful, This may help other community users to follow correct solution.
Regards,
Riya Verma