Getting Values from GlideRecord
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-15-2015 01:48 PM
I'm fairly new to Jelly and the ServiceNow platform in general. I'm trying to build a UI Page and I have the shell of my HTML built but I'm having some trouble accessing the values in the GlideRecord. I have this code in place:
<g:evaluate var="jvar_cmg_io" object="true" jelly="true">
var io = new GlideRecord('x_cmgrs_digital_io_intake');
io.addQuery('status', 'Open');
io.addQuery('number', 'ORD0002455');
io.query();
</g:evaluate>
Then, later when I try to output the Order Number for instance, I'm not getting any output.
<strong>Order Number:</strong> ${ jvar_cmg_io.number }
Any help would be much appreciated. Thanks.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-15-2015 02:47 PM
One thing to check is this bit:
io.addQuery('status', 'Open');
The status will need to query the value of the status not the label. Value is usually a number like:
io.addQuery('status', '1');
Manjul's '<j:while test=' loop is a good idea, but i'd modify it to:
<p>Order Number:<strong> ${HTML:jvar_cmg_io.getValue('number')}</strong> (${HTML:jvar_cmg_io.getValue('status')})</p>
or similar to help figure out what status value you are looking for.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-15-2015 02:58 PM
Thanks Ben,
Seems like I'm having issues with the query in general, so I'll give that a shot once I've verified that my basic query is set up correctly.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-15-2015 03:35 PM
Hmm, perhaps a security constraint? Either ACL or a role directly on that table?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-16-2015 01:21 PM
I asked our Tech Consultant about that and he said: "I checked, you have no ACL restraining you."
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-15-2015 05:34 PM
Activate elevated privileges and test your JavaScript in the Background Script module.
If that works then at least you know that your JS is fine.