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

Hi,

then this should work fine

Please check if the alert comes?

var subjectPerson = g_form.getReference('subject_person',doAlert);

function doAlert(subjectPerson)
{
	if(subjectPerson.location == 'locationSysId'){
		alert('Inside if');
		g_form.setValue('fieldName', 'fieldValue');
	}
}

Regards
Ankur

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

alert is not displaying.

please share complete script here and the configuration screenshot.

also share the form screenshot

Regards
Ankur

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

Shakeel Shaik
Giga Sage
Giga Sage
var subjectPerson=g_form.getReference('subject_person',doAlert);

function doAlert(subjectPerson)
{

if(subjectPerson.getDisplayValue('location') == 'XYZ')
{

g_form.setValue('field Name', subjectPerson.getValue('location'));
}

}
Thanks,
Shakeel Shaik 🙂

Imran Ahmad1
Kilo Guru

Hii @Ulka 

 

Copy and paste the code in your client script:-

 

var user = g_form.getReference("caller_id",callback);

function callback(user){

if(user.getDisplayValue("location")=="ABC"){

g_form.setValue("field name",user.location);

}

}

 

Regards,

Imran Ahmad

 

If Correct Mark as Correct Answer:-

Please Mark Helpful below:-