How to fetch reference field data in catalog client script or in script include
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-03-2022 12:28 AM
Hi Expertise,
I need to fetch reference field(like caller) data such as location which is stored in sys_user table and then I have to use this location in catalog client script. so please could anyone suggest me how to achieve this one. I tried getReference method but it is not working.
Awaiting for your response.
Thank You,
Ulka
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-03-2022 12:34 AM
Hi,
please use getReference() with callback method and then only it would work in portal
Normal getReference() won't work in portal
Please share your script
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-03-2022 01:02 AM
Hi Ankur,
Thanks for the response.
Below is the catalog client script which i wrote, please take a look and suggest where I am getting wrong.
var subjectPerson=g_form.GetReference(subject_person',doAlert);
function doAlert(subjectPerson)
{
if(subjectPerson.location='XYZ')
{
g_form.setValue(field Name', 'field value');
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-03-2022 01:05 AM
var subjectPerson=g_form.getReference('subject_person',doAlert);
function doAlert(subjectPerson)
{
if(subjectPerson.location='XYZ')
{
g_form.setValue(field Name', 'field value');
}
Note: Ignore previous script check this one. subject_person is the reference field and i want to fetch its location.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-03-2022 01:06 AM
Hi Ankur,
Thanks for the response. below is the catalog client script which i wrote.
var subjectPerson=g_form.getReference('subject_person',doAlert);
function doAlert(subjectPerson)
{
if(subjectPerson.location='XYZ')
{
g_form.setValue(field Name', 'field value');
}
check this one. subject_person is the reference field and i want to fetch its location.