How to set value to reference field using sys_id
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-26-2016 02:37 AM
Hi all,
I am having sys_id of company name and i want to set that company name to reference field using sys_id.So how to do it?Please anyone can tell?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-27-2016 03:43 AM
Hi Berny,
Thank you so much for your help.I got the issue solved.
Thanks,
Nikhil
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-27-2016 05:26 PM
That's great Nikhil peshwen! Would you mind marking the answers as correct/helpful so that we can close this thread?
Thanks,
Berny
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-12-2017 12:47 AM
I am referring to user table for a field.The "first name" value should be displayed when I select the user from the list.But the display value is set to true for "name " field,which should not to be changed.So,Is it possible to display the first name without changing the display value.Any suggestions..

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-27-2016 01:19 AM
Hi Nikhil,
The one Berny has suggested above will solve your problem I guess.
Because you are declaring the variable answer inside the function and using that outside it , where the scope of variable is not there.
As a best Practice , it is better to set Value and display value while using setValue function.
g_form.setValue(fieldName, value, [displayValue])
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-26-2016 03:18 AM
Hi,
Best practice would be to provide both the sys_id and display value if you have them. This saves one extra lookup.
Take a look at the wiki GlideForm (g form) - ServiceNow Wiki under the section labelled 11.5 setValue