Populate reference Field with value when choice list is answered

Sam Ogden
Tera Guru

Hi All,

On our change_request form I have added 3 new fields to a tab called Completion and PCR:

u_chase_status - choice list

u_date_chased - date field

u_person_chased - reference to the sys_user table

u_chase_status is a choice list with dropdown including none with the following options:

find_real_file.png

If anything other than --none-- is selected(i.e. values 1,2 or 3) then I want the u_person_chased to be populated with the person in the requested_by field on our change request form.   I need this to display to the operator when they select one of the answers.   Once it has been saved they still need to be able to manually select a different user.

I have tried to write a client script, but this is not working:

find_real_file.png

Any help on where I have gone wrong is greatly appreciated.

Thanks

Sam

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Sam,



You have done a mistake in the script.


1) error while populating the u_person_chase field from requested by. you did not fetch the value of requested_by field instead wrote name of the variable there


2) error while comparing the values



Updated script:



if(chase = '1' || chase == '2' || chase == '3'){


g_form.setValue('u_person_chase', g_form.getValue('requested_by'));


}



Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.


Thanks


Ankur


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

View solution in original post

5 REPLIES 5

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Sam,



You have done a mistake in the script.


1) error while populating the u_person_chase field from requested by. you did not fetch the value of requested_by field instead wrote name of the variable there


2) error while comparing the values



Updated script:



if(chase = '1' || chase == '2' || chase == '3'){


g_form.setValue('u_person_chase', g_form.getValue('requested_by'));


}



Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.


Thanks


Ankur


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

Thanks for the above, I knew that I would have made a silly mistake.  



All working now



Thanks


Hi Sam,



Could you also mark the answer as helpful and hit like. Thanks in advance.



Regards


Ankur


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

No problem,