- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-30-2017 07:47 AM
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.
Solved! Go to Solution.
- Labels:
-
Service Portal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-31-2017 05:42 PM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-30-2018 05:56 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-30-2018 03:44 PM
Hi avivs,
Sorry for the confusion, this thread has grown and has becomed hard to follow.
Try replacing this section of the server side script
var dV = gr.getDisplayValue('watch_list');
var sV = gr.getValue('watch_list');
data.displayValue = dV == '' ? [] : dV;
data.value = sV == null ? [] : sV;
With this:
data.displayValue = gr.getDisplayValue('watch_list') || '';
data.value = gr.getValue('watch_list') || '';
Also testing the widget, I saw a different bug when trying to empty the watch list nothing was saved. So replace:
if(input && typeof input.watchList){
With:
if(input && typeof input.watchList != 'undefined'){
If these adjustements don't work don't hesitate to reply. Try to include any javascript error appearing in the browser console if it is the case.
Since this thread is already hard to follow, I will update the code that you used in my previous reply.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-31-2018 03:17 AM
It's working now! Thanks a lot Laurent 🙂
BR,
Aviv

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-30-2018 08:04 PM
Thanks for this!
I've worked this in with some other "ticket management" features I've built.
One question, do you know how I could add a second piece of information? Like some of our users have the same first and last name. We've used added their title as an additional field of information from their sys_user profile on things like the "Caller" field etc.. Any advice on how to sort of merge the name and then have their title show as well?
(Edit: got sort of close...but now when I refresh it's showing their sys_id, instead of just the name. bah!)
<sn-record-picker field="watch_list" sn-disabled="!data.canWrite" table="'sys_user'" display-fields="'name';'title'" search-fields="'name'" value-field="'sys_id'" default-query="'active=true^web_service_access_only=false^user_nameISNOTEMPTY'" multiple="true"></sn-record-picker>
It seems as soon as there's two pieces of information what gets displayed back in the box is their sys_id, but when searching it shows their name and then their title underneath their name sort of "subscript" like.
Almost got it!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-07-2021 12:28 AM
Hi Laurent,
Can I use this in 'Catalog Checkout Custom' widget? I've added a watchlist field in the popup widget but I don't know where to insert the code since it has a custom checkout button.
Thanks