How to get a watch list in widget in Service Portal ?

Nithin12
Tera Expert

Hi Team,

How to get watch list for a particular ticket opened in service portal.

How to create a widget for this?

Any suggestions or ideas will help me a lot.

Thanks.

PlatformDeveloper Community

1 ACCEPTED SOLUTION

Hi Nithin,



Here is a quick widget I made, however it does not have any save functionality so you would have to add that. Also the sn-record-picker does not allow to add an email address as the usual watch list field does. If your goal is only to display a read of what was set on creation than this would do the job by simply setting sn-disabled="true".



HTML:


<div ng-if="data.canRead" class="panel panel-primary b">


  <div class="panel-heading">


      <h4 class="panel-title pull-left">


          ${Watch list}


      </h4>


      <div class="clearfix"></div>


  </div>


  <div class="panel-body">


          <div class="text-center text-italic text-muted">


              <sn-record-picker field="watch_list" sn-disabled="!data.canWrite" table="'sys_user'" display-field="'name'" search-fields="'name'" value-field="'sys_id'" default-query="'active=true'" multiple="true"></sn-record-picker>


          </div>


  </div>


</div>



Client script:


function($scope, spUtil) {


      var c = this;


     


      $scope.watch_list = {  


              displayValue: c.data.displayValue,  


              value: c.data.value,


              name: 'watch_list'  


  };


}



Server script:


(function() {


     


      var table = $sp.getParameter('table')


      var sys_id = $sp.getParameter('sys_id')


      var gr = new GlideRecord(table);


      if(gr.get(sys_id)){


              data.canRead = gr.watch_list.canRead();


              data.canWrite = gr.watch_list.canWrite();


              if(data.canRead){


                      data.displayValue = gr.getDisplayValue('watch_list');


                      data.value = gr.getValue('watch_list');


              }


      }


})();



I know this is incomplete but I hope it helps.


View solution in original post

65 REPLIES 65

Hello,

Sorry, not understanding your issue here. SN has widgets that you can set that filter on...yourself. So there's a simple list widget that is OOB, then you can filter that to only show tasks that are relevant to you (various cases here...but if they're assigned to you? If you're on a watch list? If you're the manager of the person working it, etc.).

Perhaps you can look in that option?

SN isn't going to create a widget specifically to show you tasks when you're added to the watch list because that is a unique use case and doesn't depict the broader use of the watch list field, etc.

Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

Where are the filters?  All I see is the HTML , Client Script, Server Script.  This is all difficult, where are the filters.  I am looking at a widget for "My Requests"  Thought I could use this and change the filters, but I have no idea where to go to do that.

Hi,

So you can go to page designer, for example, pick a page you want to add a list of records on, then again for example...search for simple list in left-hand search then drag that widget onto your canvas where you want the widget to go. From there, you can click the pencil icon to get in to it's settings:

find_real_file.png

Which brings you settings such as:

find_real_file.png

From here, you can set the filer by using an encoded query type string, such as: active=true or...the less advanced way would be to at least set some of the initial settings: table, display field, etc. and then save...

find_real_file.png

Now that it's placed on your page, back in your back-end view of SN, you can search for "widget instances" and then sort by last updated and you'll see your widget that you placed on that page, click that record. Once you click that, the filter is right there and you can set it up accordingly.

For your case, I would use something like this:

find_real_file.png

Now, when you go back to your service portal page this widget is on, it'll be filtered accordingly.

BONUS TIP:

I would recommend adding the "Order by" and "Order direction" to your widget instance form (my preference is within the "Table & Filter" section), like so:

find_real_file.png

Doing this allows you a bit more control around HOW the data shows in this list and not just WHAT.

So I want these always filtered by newly updated showing first, so I'd use these settings:

find_real_file.png

So then on my portal it looks like this:

find_real_file.png

Have fun!

Please mark reply as Helpful, if applicable. Thanks!

 

 


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

pagdenl
Giga Expert

OMG this was extremely helpful, it is working perfectly.  I can't believe how easy that was.  

 

Just one more thing.  This maybe a dumb question...  So the widget name is Requested Items, how do I change that to Watchlist items??

 

find_real_file.png

pagdenl
Giga Expert

Holy Moly I just figured that out...  Thanks you so very much for all your help Allen..  wow now onto another simple list widget...  Amazing... Love the community help...