# Some filtering/sorting doesn't work on CPF?

**URL:** <https://forums.losant.com/t/some-filtering-sorting-doesnt-work-on-cpf/5627>\
**Category:** Help\
**Tags:** cpf\
**Created:** [October 2, 2024, 1:22pm UTC](https://forums.losant.com/t/some-filtering-sorting-doesnt-work-on-cpf/5627 "2024-10-02T13:22:41Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tanner\_Williams](https://avatars.discourse-cdn.com/v4/letter/t/e274bd/32.png) [@Tanner\_Williams](https://forums.losant.com/u/Tanner_Williams)\
**Post date:** [October 2, 2024, 1:22pm UTC](https://forums.losant.com/t/some-filtering-sorting-doesnt-work-on-cpf/5627/1 "2024-10-02T13:22:41Z")

</div>

The sorting on the events table doesn’t seem to be working, I don’t believe the work flow or the html were ever changed at any point, what makes it weirder is that the sorting does work on other pages such as the devices table.

Also along with that the icon for an “info event” also does not load/show.

Not exactly sure how the filtering works so Im not sure what could’ve broke it.

Lastly the arrows to navigate pages, and the drop down to change the number of events doesn’t work either.

Info Icon not showing, other icons are showing:  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/getstructure/original/2X/2/28d63998b9a7ec26f01baafc51c70a575747b0b9.png)

Sorting not working on the events table:  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/getstructure/original/2X/a/a485003fa2d4c50a0c3ff0300a8cc946d1098cb8.png)

Sorting working on devices table:  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/getstructure/original/2X/7/7710aa40f8d0aaabc291736dbd404e0a10f5dda8.png)

---

<div class="post-metadata">

**Author:** ![Dylan\_Schuster](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/dylan_schuster/32/2850_2.png) [@Dylan\_Schuster](https://forums.losant.com/u/Dylan_Schuster)\
**Post date:** [October 2, 2024, 2:28pm UTC](https://forums.losant.com/t/some-filtering-sorting-doesnt-work-on-cpf/5627/2 "2024-10-02T14:28:09Z")

</div>

Just for clarification, you’re saying “sorting” a lot but I think you mean “filtering”? As in, sorting being the order in which results are returned and filtering being limiting which results are returned?

> Also along with that the icon for an “info event” also does not load/show.

I can confirm this and have filed a bug ticket. We’ll investigate; it’s probably an easy fix and we’ll let you know how to apply it to your version of the template.

> Sorting not working on the events table:

I’m not seeing this issue in the base template. Is the table refreshing when you change the value in the “Customer” dropdown but just returning the same results, or is nothing happening?

- If refreshing with the same results, I would check the workflow that is rendering that table and verify that the requested value is being passed through to the Event: Get Node. In the base template, this is an experience workflow called “cpf-element-events-table”. (See attached)
- If nothing is happening, I would check your browser console to see if an error is being thrown somewhere that would prevent the request from going through. (In this case you would not see the workflow execute.)

 ![Screenshot 2024-10-02 at 10.25.04 AM](https://us1.discourse-cdn.com/flex015/uploads/getstructure/original/2X/3/338eb1e4299af75ca1b46278238128c6e4fcf960.jpeg)

> Lastly the arrows to navigate pages, and the drop down to change the number of events doesn’t work either.

This issue I am not seeing. My recommendation is the same as the previous - verify that a request is being made when changing pages and that the page number / per-page values are making it to the workflow if so.

---

<div class="post-metadata">

**Author:** ![Tanner\_Williams](https://avatars.discourse-cdn.com/v4/letter/t/e274bd/32.png) [@Tanner\_Williams](https://forums.losant.com/u/Tanner_Williams)\
**Post date:** [October 2, 2024, 2:35pm UTC](https://forums.losant.com/t/some-filtering-sorting-doesnt-work-on-cpf/5627/3 "2024-10-02T14:35:53Z")

</div>

I looked both of those place initially as well, neither seem to show anything, these are taken after me loading the page, then clearing the console and debug, then trying to filter or change pages

weirdly enough the only one that showed anything at all was the date filter which did change the filtering and trigger the work flow, other than that nothing in console or on debug

 ![image](https://us1.discourse-cdn.com/flex015/uploads/getstructure/original/2X/c/cdcef7af1de737113976d7b32a9fe2f06f085405.png)  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/getstructure/original/2X/d/d73de2de371d2a7b577901e1659f1800929e5f2a.png)

---

<div class="post-metadata">

**Author:** ![Dylan\_Schuster](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/dylan_schuster/32/2850_2.png) [@Dylan\_Schuster](https://forums.losant.com/u/Dylan_Schuster)\
**Post date:** [October 2, 2024, 2:39pm UTC](https://forums.losant.com/t/some-filtering-sorting-doesnt-work-on-cpf/5627/4 "2024-10-02T14:39:33Z")

</div>

Fix for the missing “info” icon -

In the experience page “cpf-element-events-table”, we simply aren’t covering the case for “info” events". In the base template, you’ll see this around line 114 …

```html
<td class="text-nowrap material-symbols-outlined cpf-icon-{{this.level}} cpf-icon-small" data-bs-toggle="tooltip" title="{{this.level}}">
  {{#eq this.level 'warning'}}
  warning
  {{/eq}}
  {{#eq this.level 'critical'}}
  explosion
  {{/eq}}
  {{#eq this.level 'error'}}
  error
  {{/eq}}
</td>

```

If you just add this as another case before the closing `</td>` tag, the icon will appear:

```hb
{{#eq this.level 'info'}}
info
{{/eq}}

```

---

<div class="post-metadata">

**Author:** ![Tanner\_Williams](https://avatars.discourse-cdn.com/v4/letter/t/e274bd/32.png) [@Tanner\_Williams](https://forums.losant.com/u/Tanner_Williams)\
**Post date:** [October 2, 2024, 2:41pm UTC](https://forums.losant.com/t/some-filtering-sorting-doesnt-work-on-cpf/5627/5 "2024-10-02T14:41:42Z")

</div>

![image](https://us1.discourse-cdn.com/flex015/uploads/getstructure/original/2X/c/cb797020b50515b8815eb5791c750475336597d6.png)  
Thank you

---

<div class="post-metadata">

**Author:** ![Dylan\_Schuster](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/dylan_schuster/32/2850_2.png) [@Dylan\_Schuster](https://forums.losant.com/u/Dylan_Schuster)\
**Post date:** [October 2, 2024, 2:58pm UTC](https://forums.losant.com/t/some-filtering-sorting-doesnt-work-on-cpf/5627/6 "2024-10-02T14:58:26Z")

</div>

This is a sanity check question but, are you sure filtering isn’t working? Based on your screenshot I tracked down your application. It does not have any events of the “Warning” level and the “Acknowledged” state - which matches up with your CPF screenshot.

 ![Screenshot 2024-10-02 at 10.57.24 AM](https://us1.discourse-cdn.com/flex015/uploads/getstructure/original/2X/7/78de95a5a7e5b2fc3f862499d6f155dd85177cfe.png)

 ![Screenshot 2024-10-02 at 10.57.47 AM](https://us1.discourse-cdn.com/flex015/uploads/getstructure/original/2X/2/2849ed24569b943003f1346262d782c1ccef01ae.png)

If you determine that filtering is indeed broken, we’ll need you to set up an experience user for us and PM us the password so we can reproduce.

---

<div class="post-metadata">

**Author:** ![Tanner\_Williams](https://avatars.discourse-cdn.com/v4/letter/t/e274bd/32.png) [@Tanner\_Williams](https://forums.losant.com/u/Tanner_Williams)\
**Post date:** [October 2, 2024, 3:02pm UTC](https://forums.losant.com/t/some-filtering-sorting-doesnt-work-on-cpf/5627/7 "2024-10-02T15:02:06Z")

</div>

The original screenshot is misleading, nothing was filtered until I changed the date range filter, then that made nothing appear

 ![image](https://us1.discourse-cdn.com/flex015/uploads/getstructure/original/2X/b/b335f4299fded762e1427146281dc03b75183925.png)

here is filtering for critical level and still having all types of levels show up  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/getstructure/original/2X/4/48d0ba463062dbc6bc65042735e99688a4728309.png)

and debug for the events table is empty  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/getstructure/original/2X/a/a697d406a1641d940c21494ab787aae86b0f2630.png)c

sure I can set that up for you how should i message you the info

---

<div class="post-metadata">

**Author:** ![Dylan\_Schuster](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/dylan_schuster/32/2850_2.png) [@Dylan\_Schuster](https://forums.losant.com/u/Dylan_Schuster)\
**Post date:** [October 2, 2024, 5:28pm UTC](https://forums.losant.com/t/some-filtering-sorting-doesnt-work-on-cpf/5627/8 "2024-10-02T17:28:39Z")

</div>

Update, I’m told this is actually an older bug that was fixed here:

> <https://github.com/Losant/losant-templates/commit/e1c8a51b5cacdea8f3ab02e1eeedf6a35373e2b8>

So if you want to port these changes into the component “cpf-js-element-events-table”, that should resolve it.

---

<div class="post-metadata">

**Author:** ![Tanner\_Williams](https://avatars.discourse-cdn.com/v4/letter/t/e274bd/32.png) [@Tanner\_Williams](https://forums.losant.com/u/Tanner_Williams)\
**Post date:** [October 2, 2024, 7:50pm UTC](https://forums.losant.com/t/some-filtering-sorting-doesnt-work-on-cpf/5627/9 "2024-10-02T19:50:38Z")

</div>

Alright thank you that seems to have fixed all my issues

---

<div class="post-metadata">

**Author:** ![Tanner\_Williams](https://avatars.discourse-cdn.com/v4/letter/t/e274bd/32.png) [@Tanner\_Williams](https://forums.losant.com/u/Tanner_Williams)\
**Post date:** [October 3, 2024, 7:35pm UTC](https://forums.losant.com/t/some-filtering-sorting-doesnt-work-on-cpf/5627/10 "2024-10-03T19:35:29Z")

</div>

@Dylan_Schuster This couldve been something that was fixed also since I got my cpf version,

I was having an issue where the filter bars would “save” two inputs, or an old input that has since been deleted.

This was preventing me from clearing out the filter again to default and showing everything

For example:

 ![image](https://us1.discourse-cdn.com/flex015/uploads/getstructure/original/2X/b/bdd5042f78b386beaed4f656f22d51d662f9f166.png)  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/getstructure/original/2X/b/bdef2ce2a3e55119ab18e91e8f9cf6161db04bd0.png)

 ![image](https://us1.discourse-cdn.com/flex015/uploads/getstructure/original/2X/3/3502198fb750cf27b276b9082ff1042b28199339.png)  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/getstructure/original/2X/9/9bd098bbc029921dff4ff652ea2dc4bbcd213f07.png)

Typing something again let me get back filtering just for the inputted text

 ![image](https://us1.discourse-cdn.com/flex015/uploads/getstructure/original/2X/9/93a7fd5c7dc59a08a731b73ec5d4aa750f43bfda.png)  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/getstructure/original/2X/1/13920410ec9b005e70bf06df0ab49e12ec6e7212.png)

clearing out the box again to default returns no devices and this is what’s sent to the query  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/getstructure/original/2X/4/497f7f77ec766233ed797c3d02e5291a169c7188.png)

I believe it is this section of code that is causing this issue (around line 110 in cpf-js-element-events-table)

```auto
let queryParams = Array.from(filterFields).map((f) => {
    return f.value !== '' ? `${f.dataset.filter}=${encodeURIComponent(f.value)}` : null
});

```

changing that to just not check for `''` seemed to fix the issue of not being able to clear the filtering for me, not sure if this would cause any other unintended interactions for but figured id just bring it up incase it hadn’t been fixed/still existed

```auto
let queryParams = Array.from(filterFields).map((f) => {
    return `${f.dataset.filter}=${encodeURIComponent(f.value)}`;
});

```

I suppose this could have also stemmed from the fact i changed it to sorting via name rather than ID but if i remember correctly i was having the issue prior to that change

---

<div class="post-metadata">

**Author:** ![Tanner\_Williams](https://avatars.discourse-cdn.com/v4/letter/t/e274bd/32.png) [@Tanner\_Williams](https://forums.losant.com/u/Tanner_Williams)\
**Post date:** [October 3, 2024, 7:40pm UTC](https://forums.losant.com/t/some-filtering-sorting-doesnt-work-on-cpf/5627/11 "2024-10-03T19:40:20Z")

</div>

It will also some times also return values like this  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/getstructure/original/2X/c/cf99feddd3eaed46aa54cdce16a66fb085224b32.png)  
which i fixed with a function node with

```auto
if (Array.isArray(payload.data.query.device)) {
    payload.data.query.device=payload.data.query.device[0];
} 

```
