
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2022 08:28 PM
Hi ,
below simple code I created but value
var gr = new GlideRecord ('cmdb_ci_server');
gr.addQuery('sys_id' , 's132432432423nh23h3223');
gr.Query()
if(gr.next());
//var msg = gr.getValue('used_for');
var msg = gr.used_for;
gs.print(" Value of choice field used_for is "+msg);
output :
Value of choice field used_for is null
anyone can help me understand why it's not getting value for purticular field when I am opening the record (cmdb_ci_server) in different table then form open record is showing - cmdb_ci_win_server ..(I am not expert in ITOM cmdb ci tables , so might be it's any relationship)
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-01-2022 01:23 AM
Hi,
This is because your script has incorrect syntax. Please use the modified code below:
var gr = new GlideRecord ('cmdb_ci_server');
gr.addQuery('sys_id' , 'b0ccabf1c0a80009001f14fd151d8df0');
gr.query();
if(gr.next()){
var msg = gr.getDisplayValue('used_for');
gs.print(" Value of choice field used_for is "+msg);
}
Result:
Issue which was there sharing it as well for learning purpose to improve in future why it was not working for you:
1) gr.Query() --> Q should be in small and there should be a semicolon
2) if(gr.next()); --> There should not be a semicolon here and there should be brackets {}, within this bracket you need to write your logic to get the value.
Hope this helps. Please mark the answer as correct/helpful based on impact.
Regards,
Shloke
Regards,
Shloke
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2022 09:01 PM
Try below:
var gr = new GlideRecord('cmdb_ci_server');
gr.addQuery('sys_id', 's132432432423nh23h3223');
gr.query();
if(gr.next()){
var msg = gr.getDisplayValue('used_for');
}
gs.info(' value - ' +msg);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-01-2022 01:23 AM
Hi,
This is because your script has incorrect syntax. Please use the modified code below:
var gr = new GlideRecord ('cmdb_ci_server');
gr.addQuery('sys_id' , 'b0ccabf1c0a80009001f14fd151d8df0');
gr.query();
if(gr.next()){
var msg = gr.getDisplayValue('used_for');
gs.print(" Value of choice field used_for is "+msg);
}
Result:
Issue which was there sharing it as well for learning purpose to improve in future why it was not working for you:
1) gr.Query() --> Q should be in small and there should be a semicolon
2) if(gr.next()); --> There should not be a semicolon here and there should be brackets {}, within this bracket you need to write your logic to get the value.
Hope this helps. Please mark the answer as correct/helpful based on impact.
Regards,
Shloke
Regards,
Shloke

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-01-2022 05:53 AM
var gr = new GlideRecord ('cmdb_ci_server');
if(gr.get('s132432432423nh23h3223'))
{
var msg = gr.getValue('used_for'); // you can user getDisplayValue too.
gs.print(" Value of choice field used_for is "+msg);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-01-2022 06:03 AM