Create a 'Add to Watchlist' button on an open case form, so that the customer can add other contacts
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-12-2022 08:22 PM
Hi All,
I have a requirement from a client, to be able to have a 'Add to Watchlist' button on all open Case forms. When this button is clicked, it should display list of contacts belonging to that case account and user should be able to select the required users from the list.
Known: (to add them to the watchlist the user must already be created within the Case portal)
Customer logs into to Case portal
Select Current Cases from the menu across the top of the page
Select an existing Case
Select "Add user to Watchlist" button
Select a user from the drop down list
User is added to the Case watchlist
User recieves Email email notifications when there is;
- A change of State to the Case
- When Additional comments are added to the Case.
I'm new to CSM, can someone please help me on this requirement
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-13-2022 11:46 PM
I have found some help and able to create a widget that would display the list of users to select and add to the watchlist. Now, i would like to filter the names displayed in the dropdown list to all the contacts of the account to which the case belongs to. Any help, where i will have to make the changes in my script?. Please find my current widget below:
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" id="watch_list_div">
<sn-record-picker
ng-blur="updateRecord()"
field="watch_list"
sn-disabled="!data.canWrite"
table="'customer_contact'"
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">
Add User to Watchlist
</button>
</div>
</div>
</div>
Client Script:
api.controller=function($scope, spUtil) {
var c = this;
$scope.watch_list = {
displayValue: c.data.watch_list.displayValue,
value: c.data.watch_list.value,
name: 'watch_list'
};
$scope.updateRecord = function(){
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
}
}
})();
Link:
function link(scope, element, attrs, controller) {
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-13-2022 11:55 PM
Is this not out of box?
If you have the watchlist field on the form, user can add people to the watchlist by clicking on the textbox. You shouldn't need a button to do that. You should also be able to add additional filter to that field if required.
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2022 08:53 PM
Yes there is one available OOB but that is on the platform. I'm talking about having a button on portal so customer can add contacts to the watchlist field of the case form
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-14-2022 08:13 PM
Hi. Did you manage to create the widget? I have the same request but am not good at scripting and can't get your code to work. Any advice will be great.