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.

Script to configure the filters in the UI Builder

Arun Kumar 659
Tera Contributor

In the Platform Analytics Academy - Crafting Insights with UI Builder, they have used a specific script to bind the the Filters with the other elements.

 

YouTube video - https://www.youtube.com/watch?v=rK7JuNJrLEw&list=PLkGSnjw5y2U6HotK0MQUbCrzVog_zBWat&index=11

 

A small part of it is not visible and I was unable to make out what it could be. Can any of you please share it if possible.

Thank you for joining us on June 12th, 2024, for an in-depth session on building Data Visualizations and Dashboards using UI Builder. This Academy session was perfect for those seeking enhanced control and customization options for their Platform Analytics Dashboards. Chapters: 00:12 Introduction
1 ACCEPTED SOLUTION

Kevin83
ServiceNow Employee
ServiceNow Employee

I think this is the script you are referring to:

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;
	});
}

View solution in original post

3 REPLIES 3

Kevin83
ServiceNow Employee
ServiceNow Employee

I think this is the script you are referring to:

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;
	});
}

Yes absolutely, thanks for sharing!!

Also, this is in the Component reference on the dev site. This reference is the go-to for configuring any UIB component. https://developer.servicenow.com/dev.do#!/reference/next-experience/xanadu/shared-components/sn-comp... (You have to scroll down as the internal page links don't work.)