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, we don't know what you know, so I provided a breakdown since you asked for it to be summarized. Now...if you meant for someone to reply to you with exact scripts that you'd need, then yeah, you will need your own space for that.

It may be better for you to create your own post so that this can be tracked accordingly, you could reference this post, but instead, we're sort of tacking on this 4+year old thread now.

The scripts above throughout this post have indicators showing which section you'd place them in. For example, the correct answer has sections marked such as: HTML, Client Script...so that is telling you to place the following scripts in to those respective sections.

As far as "nothing" appearing, you'd then need to place the widget on the page that you'd like to see it on. If it's at least somewhat set up correctly, the widget should show.

Again, you may want to create your own post so that the discussion can be tracked properly for your issue. Because here we're not even getting a clear understanding of what steps you have or have not done, what steps within the portal page designer you've done, what script(s) you've ended up using (since there's been various edits above, etc.).

Please mark reply as Helpful, if applicable. Thanks!


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