How to retrieve list field first value from sys_choice table using BR
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-08-2023 12:34 AM
Hello,
I have a requirement to query to get list field value from sys_choice table to update the field value.
how to query to get list view first record using BR.. please help me on this..
Thank you in advance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-08-2023 12:58 AM
Hello @lakshmi_laksh the script will be like this.
var gr = new GlideRecord('sys_choice');
gr.addEncodedQuery('copied query'); //you can copy the query if you click on breadcrumb besides filter.
gr.query();
if(gr.next())
{
var fieldvalue = gr.value.getDisplayValue();
}
Please hit the thumb and Mark as correct based on Impact!!
Kind Regards,
Ravi Chandra.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-08-2023 01:22 AM
Thanks @Ravi Chandra_K ,
The thing is i need to get 'name' from "im_category" table that matches with 'label' from sys_choice table and update the value in list field choices.. on the idea table
tried with below code.. not working
issue with addEncodedquery..
need to get first value from list record value from sys_choice table.
var choice = new GlideRecord('sys_choice');
choice.addEncodedQuery('name=dmn_demand^element=investment_type^label=' + current.u_category);
choice.query();
if (choice.next()) {
// var a = choice.getValue('value')
grd.investment_type = choice.value.getDisplayValue();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-08-2023 01:28 AM
Hello @lakshmi_laksh
are you writing business rule on im_category table?
what is grd variable in the script?
If you want to update the value on current table then you can write
current.investment_type = choice.value.getDisplayValue();
I would suggest to use the log statements in between to know what values you are getting.
Please hit the thumb and Mark as correct based on Impact!!
Kind Regards,
Ravi Chandra.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-08-2023 02:09 AM
You can add setLimit(1) in the glide query, so it will retrieve only one record and also you use order the records too