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.

How to create custom intra active filter

lucky24
Tera Contributor

Hi Team,

I have created a dashboard and reports on the user table and I want to add interactive filters for the name field on the user table but there is no interactive field for the string type field.

I need to create a custom interactive filter for the name field on the user table so we can search any record from the user name.

I  want to include the condition active is true

I am not sure how to write code can someone help me?

Thanks

1 ACCEPTED SOLUTION

@lucky24 

Add Following code:

<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
 <div class="row" style="margin-left:10px; margin-right:10px">
	<div class="col-md-3"  style='width:330px'> 
		<p style="font-size:15px"><b>User Name</b></p>
		<input id='user_name' type = "text" onchange='filterUser()' ></input>
	</div>
	</div>
   <script>
     var dbh = new DashboardMessageHandler("filter_tasktype");
     function filterUser(){
        var userName = $j('#user_name').val();
		var filter_message = {};
         filter_message.id = "taskFilter"
         filter_message.table = "sys_user"
         
        if ((userName != '' )) {
            filter_message.filter = "nameLIKE"+userName;     
            SNC.canvas.interactiveFilters.setDefaultValue({
                id: filter_message.id,
                filters: [filter_message]
            }, false);
         dbh.publishFilter(filter_message.table, filter_message.filter);
        }
   else {
        filter_message.filter = "";     
            SNC.canvas.interactiveFilters.setDefaultValue({
                id: filter_message.id,
                filters: [filter_message]
            }, false);
            dbh.removeFilter();
        }
     }
</script>
</j:jelly>

 

Please mark correct/helpful if this helps you!

View solution in original post

7 REPLIES 7

lucky24
Tera Contributor

Thanks @Unique45 

Thank u for solution

lucky24
Tera Contributor

Hi @Unique45,

Thank u for the solution

@lucky24,

Welcome! 😊

I would appreciate, if you give helpful 👍 as well to my solutions. 

 

Please mark correct/helpful if this helps you!