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

Glad you figured it out and found that the quick tutorial I gave above was helpful!


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

Chuck S2
Giga Contributor

Can somebody summarize this whole thing again as it has gotten very convoluted. Just trying to add an editable watch_list to a normal ticket after submitted (like you can add an attachment after the ticket has been submitted). Thanks!

Chuck S2
Giga Contributor

Can somebody summarize this whole thing again as it has gotten very convoluted. Just trying to add an editable watch_list to a normal ticket after submitted (like you can add an attachment after the ticket has been submitted). Thanks!

Hi,

Basically, there is no out of box solution for this. So what is being described above is a custom widget being created to achieve the Watch List functionality you described. Out of box the ticket isn't something where people come back and change things. So...you can either create a custom widget to allow the user to add and remove people from the Watch List as needed or...simply educate users to add a comment to the ticket and the technician within the fulfiller view can do it (if this is all too much).

Hope that helps explain things!

Please mark reply as Helpful, if applicable. Thanks!


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

Chuck S2
Giga Contributor

Hi Allen, thanks for responding. I know I'll have to create a new widget, but not being familiar with service portal, I have no idea what needs to go into each field. I created a new widget that I called "edit watch list" and tried to cut and paste what I saw in this thread, but nothing is working. There are fields for :

Body HTML Template

CSS

Server Script

Client Controller

Controller as

Link

And nothing I have tried to put in any of these fields is working or even appearing on the portal.

 

Any help would be appreciated. Thanks!