CSM cases with different channel NEED TO BE RESTRICTED for different account
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-08-2023 03:47 AM
Below mentioned requirement:
Control what type on Cases a client can see. Ex: Alert cases- some clients need to see the Alert Cases for other clients we do not want them to see Alerts.
The Idea:
A field on the Account table ( Case View Restriction) will need to be created. This field would be a dropdown(multi Select) with the list that matches the Channel field that is on the cases. the field on the Account table would control what cases a client would see based on what the Channel field on the Case is set to.
Default value is all existing accounts can see (ALL) cases. Managers will update the field ( Case View Restriction) to restrict what should not be able to see.
Field Name = Case View Restriction . We would like to see this on the form/list view
Channel fields:
Web
Phone
Email
Chat
social
community
Alert
Virtual Agent
eBonding
Project
What i did for this-
created list type field on the account table 'case view restriction'
under reference selected choice table
filter condition Table - case table
element - contact_type (channel)
In this way i have used same choices of channel on the case table to newly added field case view restriction (list field)
created business rule on case table before query but not working ....
var channel = current.contact_type;
// Check if there's an associated account
if (current.account) {
// Query the associated account to get the "Case view restriction" field value
var account = new GlideRecord('Customer_account');
if (account.get(current.account)) {
// Check if the current contact matches the contact on the account
if (current.contact == account.contact) {
// Check the value of the "Case view restriction" field on the associated account
var accountRestriction = account.u_case_view_restriction;
// Check if the selected channels match the restriction
if (isChannelRestricted(channel, accountRestriction)) {
current.can_read = false; // Restrict access
} else {
current.can_read = true; // Grant access for other channels
}
}
}
}
function isChannelRestricted(caseChannel, accountRestriction) {
// Check if the selected channels match the restriction
var restrictedChannels = accountRestriction.split(','); // Assuming values are comma-separated
return restrictedChannels.includes(caseChannel);
}
Let me know what could be reason or any other solution
It is for CSM PORTAL case view restriction
Thanks in Advance !
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-12-2023 07:00 AM
created script include still not working
var CaseViewFilterUtils = Class.create();
CaseViewFilterUtils.prototype = {
initialize: function() {},
doesNotHaveValidCaseViewRestriction: function(currentCase) {
// Assuming 'account' is the reference field on the Case table pointing to the Account table
var account = currentCase.account;
// Check if the account reference is valid and has a non-empty u_case_view_restriction field
if (account && account.u_case_view_restriction) {
// Get the selected channels from the account's u_case_view_restriction field
var selectedChannels = account.u_case_view_restriction.split(',');
// Check if the case's contact type is NOT in the selectedChannels array.
return !selectedChannels.includes(currentCase.contact.contact_type);
}
// No restriction, user should see the case.
return true;
}
};
any suggestions how to call this in csm portal widget filter
  
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-15-2023 07:48 AM
i have created below script include
and called in portal filter with
javascript:CaseVisibilityUtils().getFilteredCaseSysIds(current.customer_account)
but still not working....anybody servicenow expert help me out in this