How to fetch reference field data in catalog client script or in script include

Ulka1
Tera Contributor

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

 

 

 

22 REPLIES 22

Ankur Bawiskar
Tera Patron
Tera Patron

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

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

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');

}

Ulka1
Tera Contributor

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.

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.