"where" formatter

Wappler Version : 2.5.1
Operating System : Mac OSX Mojave v10.14.5

Archive.zip (2.5 KB)

Details

I’m trying to sum the salaries of 2019 & 2020 from the child repeat to display the same in the parent row.

I’m getting javascript errors in my console, below is my expression. Wondering if this is a bug with the “where” formatter.

child.items.where("year","==","2019").sum("salary").default(0)

Please correct me if I have to fix my expression. Thanks in advance.

Try to enclose the year parameter in back tics and not quotes

Thanks @George for the quick response.

Tried changing the quotes to back-tick like this, still not working.

child.items.where(`year`,"==","2019").sum("salary")
child.items.where(`year`,`==`,`2019`).sum("salary")
child.items.where(`year`,`==`,`2019`).sum(`salary`)

Btw, I’m on a mac, and I have never seen wappler using back-ticks, is that a windows-thing?

Updated dmxFormatter.js shared by patrick in the other thread fixed half of the problem which is the sum function is getting triggered without any console errors. Both double-quotes & back-ticks seemed to work.

But, the where function is still not working, hence is sum is returning the unfiltered total as below.

thay should be

child.items.where(`year`,"2019","==").sum("salary")

or

child.items.where("year","2019").sum("salary")

the type of quotes doesn't matter, but the == parameter should be on the 3rd place or leave it away since == is the default operator.

1 Like

Thanks @patrick. That fixed it…

I think i got confused with the syntax as they are different between server-connect versus app-connect, the parameter is in different locations in the function calls as below. Thanks anyway for the clarification.

image image