Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

UI Builder Interactive filters

Vedavalli
Kilo Sage

Hi 

I've used filter component in ui builder and data visualisation component. so when i select something in filter that should be applied to data visualisation component .

I've followed this article : "https://developer.servicenow.com/dev.do#%21/reference/next-experience/utah/shared-components/sn-comp...

but it's not working.

I've created client state parameter, client script and i've attached that script to event of the filter component.

client script:

function handler({
    api,
    event,
    helpers,
    imports
}) {
    const mergePARFiltersV2 = imports["global.mergePARFilters"]().v2;
    const {
        appliedFilters
    } = event.payload;
    api.setState("parFilters", ({
        currentValue,
        api
    }) => {
        const {
            parFilters
        } = mergePARFiltersV2(currentValue, appliedFilters);
        return parFilters;
    });
}
Please need help

Thanks in advance.





1 REPLY 1

Silviu100
Tera Contributor

Hi, 

 

The correct version of the function is: 

 

function handler({ api, event, helpers, imports }) {
	const mergePARFiltersV2 = imports["global.mergePARFilters"]().v2;
	const { appliedFilters } = event.payload;
	api.setState("parFilters", ({ currentValue, api }) => {
		const { parFilters, encodedQueries } = mergePARFiltersV2(
			currentValue,
			appliedFilters
		);
		api.setState("encodedQueries", encodedQueries);
		return parFilters;
	});
}

 

Also, have a look at: 

https://developer.servicenow.com/dev.do#!/reference/next-experience/xanadu/shared-components/sn-comp...