Query a choice list by it's display value
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2018 03:43 AM
I have a table with a field "Type". This field is a choice list where choices label and value are different. Ex:
Label - Value
Email - 1
DB - 2
CRM - 3
How do I use gliderecord to query this field by it's display value ?
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2018 04:11 AM
you can use
gr.fieldName.getDisplayValue()
or
gr.fieldName.setDisplayValue()
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2018 04:18 AM
I need to write a query like this:
var gr = new GlideRecord('tableName');
gr.addQuery('field display value', '=','email');
gr.query();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2018 04:31 AM
Just tried to run this
var gr = new GlideRecord('change_request');
gr.addQuery('sys_id', 'e2cdf552db252200a6a2b31be0b8f57f');
gr.addQuery('risk.label', 'high');
gr.query();
if(gr.next())
{
gs.print(gr.number);
}
It works
So you can use
gr.addQuery('fieldName.label', 'Email');
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2018 04:46 AM
it doesn't work on my instance.
if I do
gr.addQuery('fieldName.label', 'Email');
gs.log(gr.getEncodedQuery());
it returns no records and in logs I get a message: "sys_idNotValidnull"