How to push SysIDs in reference field

Maddysunil
Kilo Sage

Hi Everyone

 

I have an arrays of sysids in client script and i want to push those sysids in a reference field in that client script. How can i push. Please help..thanks in advance

7 REPLIES 7

AnveshKumar M
Tera Sage
Tera Sage

Hi @Maddysunil ,

You can only set only one value to the reference field using g_form.setValue('field_name', <sys_id>);

 

If you want to set multiple sys_ids, the field should be of type list collector.

 

If you have sys_ids for different fields in an array, you can use key of array to set the field value.

 

 

Thanks,
Anvesh

Pavankumar_1
Mega Patron

Hi @Maddysunil ,

you can not set multiple values on client side. you can multiple values only for list field then use below script.

var users = ['804464ec2fca9810c5a950492799b698', '6816f79cc0a8016401c5a33be04be441'];
    g_form.setValue('watch_list', users);
If it helps please click Accept as Solution/hit the Thumb Icon.
ServiceNow Community MVP 2024.
Thanks,
Pavankumar

Hi Pawan...got your point thanks..so now i m not using that client script , I am using advance reference qualifier now on that reference field and trying to get current page URL on script include side as i need some parameters  , Is there any way we can get URL in script include?

Hi @Maddysunil ,

Yes, you can pass current values in script include and set URL on script include itself.

sysid is the key to every record if you pass current sysid and then set url.

Refer below

https://www.servicenow.com/community/developer-forum/how-to-pass-current-record-field-values-in-the-...

https://www.servicenow.com/community/itsm-articles/different-ways-to-get-a-record-url-and-generate-c...

If it helps please click Accept as Solution/hit the Thumb Icon.
ServiceNow Community MVP 2024.
Thanks,
Pavankumar