Filters are not working

Raghu Ram Y
Kilo Sage

I was unable to apply filter condition in Nxt Exp,  even after selecting some filter, filter is not getting applied and also reports are not getting refreshed accordingly..

1 ACCEPTED SOLUTION

JagjeetSingh
Kilo Sage
Kilo Sage

Hi,

 

This is how you can get the reports to work for your filter component.

 

1. Create a client state parameter on your page. Here I am using "parFilters" of JSON type.

JagjeetSingh3_0-1668399307504.png

2. Create a client script and add below code.

 

    //Set the filter
    api.setState('parFilters', ({
        currentValue
    }) => {
        const {
            payload: {
                appliedFilters
            }
        } = event;
        return imports['global.mergePARFilters']()(currentValue, appliedFilters); //The visualization components are built to listen to filter events.
    });

 

 

Add script include "mergePARFilters" to the client script. 

JagjeetSingh3_1-1668399444966.png

3. Make sure your data visualization component is set to follow the filter.

JagjeetSingh3_2-1668399526348.png

 

4. Trigger your client script(created in step 2) from your filter component events.

JagjeetSingh3_0-1668428405529.png

 

 

That's it! 🙂

 

 

 

Jagjeet Singh
ServiceNow Community Rising Star 2022/2023

View solution in original post

4 REPLIES 4

Raghu Ram Y
Kilo Sage

JagjeetSingh
Kilo Sage
Kilo Sage

Hi,

 

This is how you can get the reports to work for your filter component.

 

1. Create a client state parameter on your page. Here I am using "parFilters" of JSON type.

JagjeetSingh3_0-1668399307504.png

2. Create a client script and add below code.

 

    //Set the filter
    api.setState('parFilters', ({
        currentValue
    }) => {
        const {
            payload: {
                appliedFilters
            }
        } = event;
        return imports['global.mergePARFilters']()(currentValue, appliedFilters); //The visualization components are built to listen to filter events.
    });

 

 

Add script include "mergePARFilters" to the client script. 

JagjeetSingh3_1-1668399444966.png

3. Make sure your data visualization component is set to follow the filter.

JagjeetSingh3_2-1668399526348.png

 

4. Trigger your client script(created in step 2) from your filter component events.

JagjeetSingh3_0-1668428405529.png

 

 

That's it! 🙂

 

 

 

Jagjeet Singh
ServiceNow Community Rising Star 2022/2023

I forgot to add step 4. Added in my response above. 🙂

Jagjeet Singh
ServiceNow Community Rising Star 2022/2023

Its not working, Can you share if you have any other solution