Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

In widget, when query table, I are not getting any value

Not applicable

Hi,

I am working on the widget, 

----------------------------------------------------------------
 server side code:-
(function() {
var gr=new GlideRecord('custom_table');
gr.addQuery('number','5f53XXXXXX1210446ef9XXXXXX');   //String type passing sys_id
gr.query();

if(gr.next()){
data.firstoption = gr.get_value('number');
}
})();


In HTML code:
<div>
{{data.firstoption}}

</div>

------------------------------------------------

Here, I am not any value in output, am I am missing any thing..??

1 ACCEPTED SOLUTION

Not applicable

Hi @Community Alums  ,

 

I think you are querying it wrong.
In the query you need to set the sys_id and then later you can use gr.getValue(field_name).
Can you please try the below code-

 

(function() {
    var gr = new GlideRecord('custom_table');
    gr.addQuery('sys_id', '5f53XXXXXX1210446ef9XXXXXX');   //String type passing sys_id
    gr.query();
    
    if (gr.next()) {
        data.firstoption = gr.getValue('number');
        gs.info('Record found: ' + data.firstoption);
    } else {
        gs.info('No record found');
    }
})();

 

 

 

View solution in original post

1 REPLY 1

Not applicable

Hi @Community Alums  ,

 

I think you are querying it wrong.
In the query you need to set the sys_id and then later you can use gr.getValue(field_name).
Can you please try the below code-

 

(function() {
    var gr = new GlideRecord('custom_table');
    gr.addQuery('sys_id', '5f53XXXXXX1210446ef9XXXXXX');   //String type passing sys_id
    gr.query();
    
    if (gr.next()) {
        data.firstoption = gr.getValue('number');
        gs.info('Record found: ' + data.firstoption);
    } else {
        gs.info('No record found');
    }
})();