- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-15-2016 11:57 AM
Not sure why I always have trouble with reference fields. I have a UI action that i nee to run a query on another table and see if a record exists if so proceed and if not cancel the UI action.
Do I need to query the table the reference is on and return the value and then use that in the query below?
var gr = new GlideRecord('incident');
gr.addQuery('u_foo','1234');
gr.addQuery('u_bar', 'whatever') // this is a reference field and i have to enter the sys ID here and not the display value for the query to run.
gr.query();
if(gr.next()){
gs.print(Yes!)
}
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-15-2016 12:04 PM
You can either use sys_id or dot walk to the display value on the table like this
var gr = new GlideRecord('incident');
gr.addQuery('u_foo','1234');
gr.addQuery('u_bar', 'sys_id goes here');
or
gr.addQuery('u_bar.name', 'Display value on the record goes here'); //assuming name is the display value on the reference table.
gr.query();
if(gr.next()){
gs.print(Yes!)
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-15-2016 12:04 PM
You can either use sys_id or dot walk to the display value on the table like this
var gr = new GlideRecord('incident');
gr.addQuery('u_foo','1234');
gr.addQuery('u_bar', 'sys_id goes here');
or
gr.addQuery('u_bar.name', 'Display value on the record goes here'); //assuming name is the display value on the reference table.
gr.query();
if(gr.next()){
gs.print(Yes!)
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-15-2016 12:09 PM
I like dot walking to the display value seems a lot cleaner . thanks that worked!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-15-2016 12:20 PM
Glad you got your question answered.