CSM Developer: Watchlist user read case in portal simplelist
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
a month ago - last edited a month ago
Hi Community,
My company is using CSM and have trouble with user in watchlist email.
I've follow step in this community post from Ashika https://www.servicenow.com/community/csm-forum/adding-contacts-on-the-watch-list-to-view-and-add-com...
Which works beautifully. But the last part that mention to adjust BR and ACL are quited unclear.
I have create new ACL for READ and WRITE using simple operator. Which is working
Contact 'iS' gs.getUserID() OR Watchlist 'CONTAINS' gs.getUserID()
role = sn_customerservice.customer
But the Business Rule part is coming unclear.
I have found that this BR Case query for customer . It is controlling 2 things: 1 Inbound actions, 2 Simple list Portal view.
I update Case query for customer on case table as this.
Condition: !new global.CSMQueryRulesUtil().useQueryRules() && gs.hasRole('sn_customerservice.customer') && !gs.hasRole('admin')
if (!gs.getSession().isInteractive() || gs.getUserID() == 'system') {
return;
} // This part let inbound action query case table
new global.CSQueryBRUtil().addCaseQueryBR(current);
But this cover the emails only. Watchlist user cannot see the case from Portal.
So I test another Business Rule Case query for customer v2
This makes Watchlist user able to see the case from portal. But this come with a cost of performance.
Condition: !new global.CSMQueryRulesUtil().useQueryRules() && gs.hasRole('sn_customerservice.customer') && !gs.hasRole('admin')
(function executeRule(current, previous /*null when async*/ ) {
if (!gs.getSession().isInteractive() || gs.getUserID() == 'system') {
return;
}
var util = new global.CSQueryBRUtil_watchlist();
var userID = gs.getUserID();
// Start with state != canceled
var queryStr = 'state!=3';
// Add contact or watch_list match
queryStr += '^NQcontact=' + userID + '^ORwatch_listLIKE' + userID;
// Optionally add role-based conditions
var condQuery = util.getQueries(current, 'sn_customerservice_case');
gs.debug('queryStr');
gs.debug('condQuery');
if (!gs.nil(condQuery)) {
queryStr += '^OR' + condQuery;
}
current.addEncodedQuery(queryStr);
In my DEV environtment I have 200K case records.
from test run in DEV. it's take 10 seconds for the record to show up. the OOTB takes a milli seconds.
FYI, I'm a low-code developer. making changes to API make me really nervous.
If you guys have suggestion I'm all in to testing!