Correct Custom SQL COUNT() Returning Null Value

Hi All,

I’ve spent a heap of time working this one out and think it may be a bug, before I open a bug report though I thought Id see if anyone else out there has found a solution to this (what should be) simple SQL query. The SQL query works perfectly in the wappler database query editor and also third party (HeidiSQL) and uses valid syntax.

Server model: NodeJS
Wappler: 5.8.2
DB: MariaDB

I’m setting a count value for the amount of SMS sends per month, my custom SQL looks like this:
aaScreenshot 2023-10-20 100628

I then set a value for it:
abScreenshot 2023-10-20 100709

However it returns a NULL value:
acScreenshot 2023-10-20 100856

I’ve tried .toNumber() to no avail, I’ve also tried variations on the SQL eg: COUNT(DISTINCT (SmsID)) also tried adding / removing ‘Global Name’.

No matter what I try, I’m getting a NULL value sent back.

Any ideas…?

Can you check what is the exact response from your custom query in your browser dev tools?

Try wrapping the variable name in “quotes”

MONTH(CURDATE())…
you mean MONTH(CURRENT_DATE()) ?

EDIT: Ignore it, it is the same

UPDATE:
Custom query returns an array so pick the first rec custCurrentMonth[0].TotalForMonth:
Please try
set Value CurrentMonthTotal = {{custCurrentMonth[0].TotalForMonth.toNumber()}}

2 Likes

Thanks to everyone who pitched in, @famousmag was correct here - its an array being returned.!

The solution was this:

You made my day @famousmag - thank you :beer:

1 Like