How to retrieve list field first value from sys_choice table using BR

lakshmi_laksh
Tera Contributor

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.

chaitrahh_0-1688801546623.png

 

5 REPLIES 5

Ravi Chandra_K
Kilo Patron
Kilo Patron

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.

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();

}

 

 

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.

Christopher096
Tera Guru
Tera Guru

You can add setLimit(1) in the glide query, so it will retrieve only one record and also you use order the records too