Contact not able to edit Watchlist on Service Portal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-24-2019 01:48 AM
Hello all
I have created a custom Watchlist widget to add only Servicenow users to a Case Watchlist.
As a system admin I can add all the users from Servicenow to any Case which works fine(See Screenshot).
But When I impersonate a contact and in their case when I try to add a User to the watchlist , I see no user in the watchlist.(See screenshot). What I want is that a Contact should be able to only add his/her colleague from the same Account/Company and not any other user.
HTML:
<div ng-if="data.canRead" class="panel panel-primary b">
<div class="panel-heading">
<h4 class="panel-title pull-left">
<a data-toggle="collapse" href="#collapse1">${Watch list}</a>
</h4>
<div class="clearfix"></div>
</div>
<div id="collapse1" class="panel-collapse collapse">
<div class="panel-body">
<span class="lock"></span>
<div class="text-center text-italic text-muted" id="watch_list_div">
<sn-record-picker
ng-blur="updateRecord()"
field="watch_list"
sn-disabled="!data.canWrite"
table="'sys_user'"
display-field="'name'"
search-fields="'name'"
value-field="'sys_id'"
default-query="'active=true^name!=NULL'"
multiple="true">
</sn-record-picker>
<p></p>
<button
type="button"
ng-click="updateRecord()"
ng-if="data.canWrite"
class="btn btn-default ng-scope">
Update
</button>
Client Script:
function($scope, spUtil) {
$scope.sVisible =false;
$scope.dVisible =false;
var c = this;
$scope.watch_list = {
displayValue: c.data.watch_list.displayValue,
value: c.data.watch_list.value,
name: 'watch_list'
};
$scope.updateRecord = function(){
if($scope.watch_list.value == ""){
$scope.sVisible =false;
c.server.update()
return;
}else{
$scope.sVisible =true;
c.data.watch_list = $scope.watch_list;
c.server.update()
}
};
}
Server Script:
(function() {
if(input && input.sys_id && input.table && input.watch_list){
var ticket = new GlideRecord(input.table);
if(ticket.get(input.sys_id)){
ticket.setValue('watch_list', input.watch_list.value);
ticket.update();
}
} else {
if($sp.getParameter('table') && $sp.getParameter('sys_id')){
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.sys_id = sys_id;
data.table = table;
data.watch_list = {
displayValue : gr.getDisplayValue('watch_list') || '',
value : gr.getValue('watch_list') || ''
};
}
}
} else {
//missing url params
}
}
})();
Please help.
Thanks in advance.
- Labels:
-
Customer Service Management

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-24-2019 01:52 AM
Hi
the canRead and canWrite methods return true or false if the if it finds any ACL for that role or not. Try giving roles or create a read and write acl on that table for that role which the Contact has.
Regards,
Omkar Mone
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-24-2019 03:36 AM
Hii Omkar
Thanks for your suggestion.
I tried this solution but it didn't work for me .

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-24-2019 03:44 AM
Hi
Can you put console.log() in server side and check what data.canRead and canWrite is returning when contact tried to edit it.
Regards,
Omkar Mone
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-24-2019 08:30 AM
Hii
It is returning true for both data.canRead and data.canWrite.