Interactive Filter: Tickets Which I am on the Watchlist

daburges
Kilo Expert

Hi all,

I am trying to create an Interactive Filter that would filter all incident tickets by those which I(dynamic) am on the watch lists for the ticket in question.

Now if I were asked to construct this my initial thought would be:

Field Type: Reference

Reference Table: user[sys_user]

        Filter: sysid is (dynamic) (my ID)

UI type: button (so users can toggle this filter on and off)

Influenced Table: Incidents

However, upon further inspection it appears the waitlist field is what is call glide list

Documentation link: Using Watch Lists - ServiceNow Wiki

does anybody know of an easy way to create this interactive filter? or would this necessarily be a custom filter? I am trying to avoid writing code for my IF's to reduce development time and keep functionality close to the service now format.

Any advice would be appreciated!

Best,

Darrion B

1 ACCEPTED SOLUTION

Hey Ankita,



just so you know, we ended up solving this problem by creating our own custom Interactive Filter which simply throws a database query:



<?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 watchlist_dashboardMessageHandler = new DashboardMessageHandler("IAmOn_watchlist");


</script>


<input id="allIncidents" type="button" value="All Incidents" onclick="watchlist_dashboardMessageHandler.removeFilter();" />


<input id="IAmOnwatchlist_" type="button" value="Only mine" onclick="watchlist_dashboardMessageHandler.publishFilter('incident','watch_listLIKEjavascript:gs.getUserID()');" />


</j:jelly>


This is actually tremendously close to the Custom Interactive Filter Example. You will notice we get the users from the watchlist in our jelly query. I got this line by litterally making it on a list filter "watchlist contains me (dynamic)" you can then RIGHT CLICK this option and choose "copy query" and you can directly paste this query into your custom IF. Otherwise, I would highlight the fact that I made a new custom name for my DashboarMessageHandler; this ensures that this filter won't get triggered by other IF's who have the same name. I hope this helps you!


View solution in original post

4 REPLIES 4

sachin_namjoshi
Kilo Patron

Watch list is glide list field.Hence, you will have to develop script include which will return sys_id of users who are on watch list of incidents.


This script include can be called from interactive filter dynamically.



Another simpler option is to use tagging functionality of platform.


You can tag any records and create interactive filters to call script include which returns records which are tagged.



http://wiki.servicenow.com/index.php?title=Creating_and_Using_Tags#gsc.tab=0



All tags are stored in label_entry tables.



Following is sample script include which returns projects which are tagged.



var GetTagged = Class.create();


GetTagged.prototype = {


      initialize: function() {


      },


  //Return Tagged Projects of Logged in Users


  GetTaggedProject:function(){


  var proj='';


  //gs.addInfoMessage("Me = " + gs.getUserID());


  var prj = new GlideRecord('label_entry');


  prj.addQuery('label.owner',gs.getUserID());


  prj.addQuery('table','pm_project');


  prj.query();


  while(prj.next()) {


  if (proj.length != null)


    {


                                              proj += (',' + prj.table_key);


   


                                  }


                                  else


    {


                                          proj = prj.table_key;


                                  }


  }


  return proj;


},



Regards,


Sachin


Hi Sachin,



We don't currently use the tagging system so I think that would take too much time if I am understanding your solution correctly. I am wondering, how would I use this tagging system to grab tickets I am on the watch list of? In this solution would I need to tag every incident so we can pull in the incident tab? In the code above this seems to just pull in all projects which the user has tagged in any way?



If we wanted to use your glide_list recomendation for simply grabbing all of the waitlist fields and checking them against my sysid what would that look like?


Hi Sachin,



You've mentioned the first solution as to call script include from interactive filter dynamically.



Can you please provide the steps to achieve the same.



I'm stuck with adding script include in interactive filter part. Any input will really be helpful.



Regards,


Ankita


Hey Ankita,



just so you know, we ended up solving this problem by creating our own custom Interactive Filter which simply throws a database query:



<?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 watchlist_dashboardMessageHandler = new DashboardMessageHandler("IAmOn_watchlist");


</script>


<input id="allIncidents" type="button" value="All Incidents" onclick="watchlist_dashboardMessageHandler.removeFilter();" />


<input id="IAmOnwatchlist_" type="button" value="Only mine" onclick="watchlist_dashboardMessageHandler.publishFilter('incident','watch_listLIKEjavascript:gs.getUserID()');" />


</j:jelly>


This is actually tremendously close to the Custom Interactive Filter Example. You will notice we get the users from the watchlist in our jelly query. I got this line by litterally making it on a list filter "watchlist contains me (dynamic)" you can then RIGHT CLICK this option and choose "copy query" and you can directly paste this query into your custom IF. Otherwise, I would highlight the fact that I made a new custom name for my DashboarMessageHandler; this ensures that this filter won't get triggered by other IF's who have the same name. I hope this helps you!