# Display a text when a binded collection list is empty

**URL:** <https://community.weweb.io/t/display-a-text-when-a-binded-collection-list-is-empty/3079>\
**Category:** How do I?\
**Tags:** binding\
**Created:** [June 16, 2023, 7:43am UTC](https://community.weweb.io/t/display-a-text-when-a-binded-collection-list-is-empty/3079 "2023-06-16T07:43:46Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![tomlagom](https://avatars.discourse-cdn.com/v4/letter/t/3be4f8/32.png) [@tomlagom](https://community.weweb.io/u/tomlagom)\
**Post date:** [June 16, 2023, 7:43am UTC](https://community.weweb.io/t/display-a-text-when-a-binded-collection-list-is-empty/3079/1 "2023-06-16T07:43:46Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Broberto](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/broberto/32/5918_2.png) [@Broberto](https://community.weweb.io/u/Broberto)\
**Post date:** [June 16, 2023, 3:50pm UTC](https://community.weweb.io/t/display-a-text-when-a-binded-collection-list-is-empty/3079/2 "2023-06-16T15:50:28Z")

</div>

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

```auto
var result = ... // your result

```

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

```auto
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:

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

```

Then you can try to do do something like:

```auto
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:

> **[Array: length - JavaScript | MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/length)**
>
> The length data property of an Array instance represents the number of elements in that array. The value is an unsigned, 32-bit integer that is always numerically greater than the highest index in the array.

---

<div class="post-metadata">

**Author:** ![tomlagom](https://avatars.discourse-cdn.com/v4/letter/t/3be4f8/32.png) [@tomlagom](https://community.weweb.io/u/tomlagom)\
**Post date:** [June 16, 2023, 4:19pm UTC](https://community.weweb.io/t/display-a-text-when-a-binded-collection-list-is-empty/3079/3 "2023-06-16T16:19:49Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Broberto](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/broberto/32/5918_2.png) [@Broberto](https://community.weweb.io/u/Broberto)\
**Post date:** [June 16, 2023, 4:30pm UTC](https://community.weweb.io/t/display-a-text-when-a-binded-collection-list-is-empty/3079/4 "2023-06-16T16:30:17Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![tomlagom](https://avatars.discourse-cdn.com/v4/letter/t/3be4f8/32.png) [@tomlagom](https://community.weweb.io/u/tomlagom)\
**Post date:** [June 16, 2023, 4:57pm UTC](https://community.weweb.io/t/display-a-text-when-a-binded-collection-list-is-empty/3079/5 "2023-06-16T16:57:33Z")

</div>

I mean:  
This is the collection

 ![image](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/4/4a600b0cf4c915d4b0b1a62728d0ea7801f7abab.png)

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!

---

<div class="post-metadata">

**Author:** ![Broberto](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/broberto/32/5918_2.png) [@Broberto](https://community.weweb.io/u/Broberto)\
**Post date:** [June 16, 2023, 5:00pm UTC](https://community.weweb.io/t/display-a-text-when-a-binded-collection-list-is-empty/3079/6 "2023-06-16T17:00:32Z")

</div>

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