Set value on reference field on record producer via client script

snowuser4
Tera Expert

Hello all,

I am trying to set a value on a field which is reference field( referring to user table) based on a choice field vis catalog client script and not successful so far, can some one please help:

find_real_file.png

 

1 ACCEPTED SOLUTION

Murthy Ch
Giga Sage

@snowuser@18 

Do you want to set the same user whenever selects New Hire?

If yes go to user table and copy the sys_id of that user and copy the name of the user.

Ex:

g_form.setValue("subject_person","75826bf03710200044e0bfc8bcbe5d2b","Fred Kunde"); value+displayValue

If its dynamic use Script Include.

 

Thanks,

Murthy

Thanks,
Murthy

View solution in original post

5 REPLIES 5

Murthy Ch
Giga Sage

@snowuser@18 

Do you want to set the same user whenever selects New Hire?

If yes go to user table and copy the sys_id of that user and copy the name of the user.

Ex:

g_form.setValue("subject_person","75826bf03710200044e0bfc8bcbe5d2b","Fred Kunde"); value+displayValue

If its dynamic use Script Include.

 

Thanks,

Murthy

Thanks,
Murthy

Saurav11
Kilo Patron
Kilo Patron

You just need to use

g_form.setValue('subject_person','sys_id');

Please mark answer correct/helpful based on impact

Hi there,

For reference fields, please apply the value AND displayValue. This is one of the most common performance scripting mistakes.

2020-10-19 setValue() reference fields/variables, use the value AND displayValue parameter

Kind regards,
Mark

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

I see thanks for correcting it