Container condition

hi
I am trying to NOT show a container if it HAS a query result.

For some reason it won’t work. I have tried it as condition and also as a show/hide attribute. I am using hasitems() and I know my query returns NO results as I run the same query in my sql profiler.

My conditional code is:

	<div class="container mb-5" is="dmx-if" id="conditional2" dmx-bind:condition="sc_UserJobSummary.data.q_UserJob_sel[0].deliverycomplete == 1 &amp;&amp; !sc_BookingReview.datasc_BookingReview.data.q_BookingReview.hasItems()">

so first to check if the booking is complete (==1) and then the query not hasItems using the ! at the front.

my sql shows it has no results (and is complete)

my SC query is identical

but the container I have this on always shows, even though it has no items in the query.

I also removed the condition and set it up as a show with the same conditions and the container always showed, again even with no results, i tried reversing it to hide and removed the !, same result.

is there a bug? or have I missed something fundamental? I have use the same type of code in other pages, other parts of this page (the hasItems) and it works, i am stumped

thanks
darren

getting this in console

parser.js:762 Formatter hasItems in expression [!sc_BookingReview.data.hasItems()] doesn’t exist for type object

You don’t need to write a custom condition. Just a simple Dynamic Attribute on your container.

Hide if recordset has items.

I tried the hide/show route and it wouldnt work either, I am going to try again, I prefered the condition because then it is properly hidden now just a css show/hide

get same error when setup as a show

parser.js:762 Formatter hasItems in expression [sc_BookingReview.data.q_BookingReview.hasItems()] doesn’t exist for type object

simplified it right down

<div class="container mb-5" id="Review" dmx-show="sc_BookingReview.data.q_BookingReview.hasItems()">

doesn’t show correctly (or hide if I use !) I am looking at two records, one has a record and one has no record, both give the same result :frowning:

That simplified version looks right. But should be dmx-hide not dmx-show?

I can use show or hide, just be using the ! on has items expression, but I have 2 browsers open, looking at 2 bookings, one of those bookings returns a recordset and the other booking does not return a recordset, but, the container shows (or hides) the same for both bookings, but they should be opposite as return different recordsets

q_BookingReview
Is this a single query or a multi records query?

single query as at most it could return one record

You can’t use hasItems() with single queries as they don’t return arrays… Not sure how you ended up with it there, but the UI doesn’t even offer it for single queries :slight_smile:

1 Like

ah ok, i typed it in, and once type in it showed in the ui, didnt think to check it the other way. so am i best to change it to a multi? just try to minimisee DB load and thought a single would be less somehow

If you want to check if a single query is empty use:

!sc_BookingReview.data.q_BookingReview

This will evaluate to true if the query returns no result.

2 Likes

you are the master, as always, fixed, thanks as always. Learn these little things each time (just need to get them to stick in the grey matter)

thanks

1 Like