Display a text when a binded collection list is empty

I have a CollectionABC list that is processing a collection in JS, then is filtered, and then is filtered again.

How can I display a text that say something like “Seems you don’t have any tasks” when CollectionABC is not returning any objects?

I know the hard way, replicate all the JS logic and code all the no-code logic in a single JS. And then do the display/not-display. Is there an easy way?

I tried doing the wwLib.getFrontDocument(“CollectionABC”) but I don’t find the returning objects to bing the logic

Do you have something like this?
Could you share some screenshots or code? It would help a lot.

var result = ... // your result

If you have results as a JS Array for example, you can do something like:

if(result.length <= 0) { 
// code to display your whatever here
// e.g. return "Seems you don’t have any tasks."
}

Edit: I see you’re talking about objects, if you have something like:

result = { /* Your object is here */ }

Then you can try to do do something like:

if(!result) { // if your result object IS undefined then .. 
// code to display your whatever here
// e.g. return "Seems you don’t have any tasks."
}

Reference:

That would be the “hard way” I mentioned because it requires you to take all your no-code filtering and sorting logic to the JS

Actually I’m not sure how you have it set up, you havent really provided much screenshots/code, but if you’re deciding what to say based on the final output, you can do these if statements on the final output, without messing with your logic.

I mean:
This is the collection

The “easy way” I imagine is to assign an “id” to the collection and try to use this Id to know the quantity of objects of the final result.

The “hard way” is coding all the filters you see in green (no-code) and all the sorting (no-code) into the JS. Then take all of that JS and replicate it into a text show/no-show JS logic.

I think now is clearer, thanks!

If you want, you can copy paste the code here into the code markup and I can have a look at it :slight_smile: