The CreatorCon Call for Content is officially open! Get started here.

gliderecord query ignoring addQuery

xiaix
Tera Guru

<?xml version="1.0" encoding="utf-8" ?>

<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">

    <g:evaluate>

            var bcc = new GlideRecord('u_bcp_site_departments');

            bcc.addQuery('sillyWilly', gs.getUserID());

            bcc.query();

    </g:evaluate>

    <g:evaluate>

              var erc = new GlideRecord('u_bcp_site_departments');

              erc.addQuery('fooBar', gs.getUserID());

              erc.query();

      </g:evaluate>

      <j:if test="${bcc.next()}">

                      <p>TEST 1</p>

      </j:if>

      <j:if test="${erc.next()}">

                      <p>TEST 2</p>

      </j:if>

</j:jelly>

Odd... I'm seeing both TEST 1 and TEST 2.

I must be missing something simple here.   These should both fail the "<j:if>" test.

1 ACCEPTED SOLUTION

You can add this property 'glide.invalid_query.returns_no_rows' so that the invalid column name query will start returning no rows.


View solution in original post

24 REPLIES 24

Excellent resource!   Thanks!   Point (4) is my situation.   I also never knew about setLimit()... this will help in other situations.


Kalaiarasan Pus
Giga Sage

Out of the box if you add a invalid field in the query, it will return all the records of the table. But if you add the property mentioned above in your instance and set it to true, invalid queries will be blocked.


<g:evaluate>


      gs.getSession().setStrictQuery(true);


      var erc = new GlideRecord('u_bcp_site_departments');


      erc.addQuery('fooBar', gs.getUserID());


      erc.setLimit(1);


      erc.query();


</g:evaluate>



Sad to say, but the above code still returns records.  



Am I using it wrong?


Clear the cache once and check. (Or Logoff and login). Sometimes properties does not take effect instantaneously.