custom field on incident same as caller field

jthomsen
Tera Contributor

Hi,

I have a custom field on the incident table that references to the sys_user table. I want to auto populate it with the same value as the caller field, as soon as the caller field is filled with any user so whenever the caller field is no empty. Could somebody share a script with me that can execute exactly that? Thanks.

1 ACCEPTED SOLUTION

Mohan raj
Mega Sage

Hi @jthomsen,

 

To auto populate the custom field as same as caller field in incident form 

 

Client Script

Script type : On change

Field : Caller 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
   if (isLoading || newValue === '') {
      return;
   }

   if(newValue != oldValue){
g_form.setValue('u_user',newValue);
}
   
}

 

View solution in original post

3 REPLIES 3

Dr Atul G- LNG
Tera Patron
Tera Patron

HI @jthomsen 

 

May i know the use case, why you need same value in custom filed?

 

https://www.servicenow.com/community/developer-articles/how-to-set-a-value-on-a-field-of-the-form-or...

 

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

Mohan raj
Mega Sage

Hi @jthomsen,

 

To auto populate the custom field as same as caller field in incident form 

 

Client Script

Script type : On change

Field : Caller 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
   if (isLoading || newValue === '') {
      return;
   }

   if(newValue != oldValue){
g_form.setValue('u_user',newValue);
}
   
}

 

Thanks that works!