Custom interactive filter drop down list.

Bryan Tay3
Mega Guru

hi there, 

noticed that there is a OOTB dynamic content "Skill Category" (sys_id 220cc440b3672300290ea943c6a8dc46) that utilise "HomepagePublisherHandler" to render a drop down box via table api.

I'm trying to look for any reference doc on how to use this class to render a drop down box.

my ultimate goal is to create a custom interactive filter that has 2 drop down which behave something similar to "cascading drop down".

Unfortunately I could not use Cascading drop down be cause it only support "AND" condition.

happy to hear if there are other better implementation example other than "HomepagePublisherHandler" / Cascading Interactive filter.

 

 

1 ACCEPTED SOLUTION

No.  Since it isn't documented, I'd be very careful in its use.  I'd actually avoid it and stick to using DashboardMessageHandler.

View solution in original post

6 REPLIES 6

hi Adam, 

have you been across any implementation that uses "HomepagePublisherHandler" below?

<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
	<script>

		var handler = new DashboardMessageHandler("skill_category");

		function getQuery() {
			var val = ''
			if($j('#reference_skill_dashboard_category_filter').val() != "All") {
				val =  $j('#reference_skill_dashboard_category_filter').val();
			}
			return 'skillm2m_category.category_pathLIKE' + val + '^EQ';
		}
		
		function publishFilter () {
			var filter_message = {};
			filter_message.id = "skill_category";
			filter_message.table = "users_by_skill_category";
			filter_message.filter = getQuery();
			SNC.canvas.interactiveFilters.setDefaultValue({
					id: filter_message.id,
					filters: [filter_message]
				}, false);
			handler.publishFilter(filter_message.table, filter_message.filter);
		}

		var categoryHandler = new HomepagePublisherHandler("skill_dashboard_category_filter",
				"select",
				JSON.stringify({
					"isPublisher":"false",
					"display_field":"name",
					"filterType":"2",
					"config":[],
					"unique_field":"code"}),
				"true");
	</script>
	<link type="text/css" rel="stylesheet" href="/styles/interactive_filters.cssx"/>
	<div class="interactive-filter">
		<div class="select2-container form-control interactive-filter__form-control select2 widget-content interactive-filter__widget-content" id="s2id_reference_skill_dashboard_category_filter" style="padding-left: 0px; padding-right:0px; width: 100%;">
			<input link="api/now/v2/table/cmn_skill_category" default_value="All" disp_value="${gs.getMessage('All')}" id="reference_skill_dashboard_category_filter" type="hidden" aria-label="${gs.getMessage('Skill Category')}" tabindex="-1" title="${gs.getMessage('Skill Category')}" class="select2-offscreen" onchange="publishFilter();"></input>
		</div>
	</div>
</j:jelly>

No.  Since it isn't documented, I'd be very careful in its use.  I'd actually avoid it and stick to using DashboardMessageHandler.