- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-01-2024 11:55 AM
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..??
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-01-2024 02:51 PM - edited 09-01-2024 02:51 PM
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');
}
})();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-01-2024 02:51 PM - edited 09-01-2024 02:51 PM
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');
}
})();