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

$[jvar_sysID] is incorrect syntax.   You are in the first phase, but are calling a second phase variable.   It would be:



Macro


<?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="jvar_sysID" jelly="true">


        var inc = new GlideRecord('incident');


inc.addQuery('sys_idd','12232');


inc.query();


var total=inc.getRowCount();


  total;


</g:evaluate>


  ${jvar_sysID}


</j:jelly>


Or:



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


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


  <g2:evaluate var="jvar_sysID" jelly="true">


        var inc = new GlideRecord('incident');


inc.addQuery('sys_idd','12232');


inc.query();


var total=inc.getRowCount();


  total;


</g2:evaluate>


  $[jvar_sysID]


</j:jelly>



The property works on both of these.


Even after changing the brace, it works for me .


True returned 0; false returned 588, all the incidents in the system.



get() returned 588 regardless of the system property' svalue.



When I had the $[jvar_sysID] in the first phase, I just got a blank page.


I used a ui macro and added that in a catalog. Does that make any difference?

I didn't check about the 'get' function though. Will give it a try tomorrow.