Getting Values from GlideRecord

rchadek
Kilo Contributor

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.

26 REPLIES 26

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.


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.


Ben Collyer
Giga Guru

Hmm, perhaps a security constraint?   Either ACL or a role directly on that table?  


I asked our Tech Consultant about that and he said: "I checked, you have no ACL restraining you."


The SN Nerd
Giga Sage
Giga Sage

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.



ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022