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 01:21 AM
var subjectPerson=g_form.getReference('subject_person',doAlert);
function doAlert(subjectPerson)
{
if(subjectPerson.getDisplayValue('location') =='XYZ')
{
g_form.setValue(field Name', 'field value');
}
Shakeel Shaik 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-03-2022 02:00 AM
HI Smudge,
i tried one also, not working. by this code we are getting the location value as i checked it by adding addInfomessage statement. Undefined value is showing.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-03-2022 03:27 AM
var subjectPerson=g_form.getReference('subject_person',doAlert);
function doAlert(subjectPerson)
{
if(subjectPerson.getDisplayValue('location') == 'XYZ')
{
g_form.setValue('field Name', subjectPerson.getValue('location'));
}
}
Shakeel Shaik 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-03-2022 01:24 AM
Hi,
try to use this
var subjectPerson = g_form.getReference('subject_person',doAlert);
function doAlert(subjectPerson)
{
if(subjectPerson.location == 'locationSysId'){
g_form.setValue('fieldName', subjectPerson.location);
}
}
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:58 AM
Ankur, let me clear my requirement,i have to first fetch the subject person's location(subject person is a reference field to sys_user table) and depending upon this location set other field value.