Need help in Business Rule
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-27-2025 11:19 PM
Hi Team ,
can any one please help me on this request?
Incidents which are assigned to CFS-CFSEdge-SUP limit view to the Opened By and the Caller and CFS-CFSEdge-SUP grp members
I have configured :- Before - query
condition - !gs.getUser().isMemberOf('CFS-CFSEdge-SUP')
(function executeRule(current, previous /*null when async*/ ) {
if (!gs.getUser().isMemberOf('CFS-CFSEdge-SUP')) {
// Check if the incident assignment group is not CFS-CFSEdge-SUP
var grpCondition = current.addNullQuery('assignment_group').addOrCondition('assignment_group', '!=', '6b9033d187c72550141931140cbb35e1');
// Check if the business service is not CFS Edge Production
// SNC Debug - start
//current.addQuery('business_service', '!=', 'CFS Edge Production');
current.addNullQuery('business_service').addOrCondition('business_service', '!=', 'CFS Edge Production');
// SNC Debug - end
}
//gs.addInfoMessage(current.getEncodedQuery());
})(current, previous);
If any end user - raising incident from the portal ,
coming below error ,
can anyone please modify my script . so that end user can see their incident ,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-28-2025 08:10 PM
you can enhance the query BR as per your requirement.
I believe I provided enough guidance in helping and directing you.
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-28-2025 08:15 PM
could you please provide me the updated script ? for me ! , i have tried not working
restrictIncidents();
function restrictIncidents() {
// if (!gs.hasRole("itil") && !gs.hasRole("sn_incident_read") && gs.isInteractive()) {
// if member then do this else use the OOB logic
if (gs.getUser().isMemberOf('CFS-CFSEdge-SUP')) {
var u = gs.getUserID();
current.addQuery("caller_id", u).addOrCondition("opened_by", u).addOrCondition("assignment_group.name", "CFS-CFSEdge-SUP");
} else {
//Do NOT restrict Incidents if SPM premium plugin is active AND user has the service_viewer role.
if (GlidePluginManager.isActive('com.snc.spm') && gs.hasRole('service_viewer'))
return;
if (GlidePluginManager.isActive('sn_fsm_itsm_mng') && gs.hasRole('wm_ext_agent'))
return;
// STRY52118544: ham_user is added to support incident read for reporting on HAM store app
if (GlidePluginManager.isActive('com.sn_hamp') && gs.hasRole('sn_hamp.ham_user')) {
return;
}
// DEF0330091: Allow query on OT Incident with sn_ot_incident_read role
if (GlidePluginManager.isActive('com.sn_ot_inc_mgmt') && gs.hasRole("sn_ot_incident_read"))
return;
// Responders should be able to access all incidents
if (gs.hasRole("sn_sow_srm.srm_responder")) {
return;
}
var u = gs.getUserID();
current.addQuery("caller_id", u).addOrCondition("opened_by", u).addOrCondition("watch_list", "CONTAINS", u);
}
}
}
could you please update my script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-28-2025 08:19 PM
try this
restrictIncidents();
function restrictIncidents() {
// if (!gs.hasRole("itil") && !gs.hasRole("sn_incident_read") && gs.isInteractive()) {
// if member then do this else use the OOB logic
if (gs.getUser().isMemberOf('CFS-CFSEdge-SUP') && !gs.hasRole('itil')) {
var u = gs.getUserID();
current.addQuery("caller_id", u).addOrCondition("opened_by", u).addOrCondition("assignment_group.name", "CFS-CFSEdge-SUP");
} else {
//Do NOT restrict Incidents if SPM premium plugin is active AND user has the service_viewer role.
if (GlidePluginManager.isActive('com.snc.spm') && gs.hasRole('service_viewer'))
return;
if (GlidePluginManager.isActive('sn_fsm_itsm_mng') && gs.hasRole('wm_ext_agent'))
return;
// STRY52118544: ham_user is added to support incident read for reporting on HAM store app
if (GlidePluginManager.isActive('com.sn_hamp') && gs.hasRole('sn_hamp.ham_user')) {
return;
}
// DEF0330091: Allow query on OT Incident with sn_ot_incident_read role
if (GlidePluginManager.isActive('com.sn_ot_inc_mgmt') && gs.hasRole("sn_ot_incident_read"))
return;
// Responders should be able to access all incidents
if (gs.hasRole("sn_sow_srm.srm_responder")) {
return;
}
var u = gs.getUserID();
current.addQuery("caller_id", u).addOrCondition("opened_by", u).addOrCondition("watch_list", "CONTAINS", u);
}
}
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-28-2025 08:39 PM
As per your instructions, I have updated BR like below.
restrictIncidents();
function restrictIncidents() {
// if (!gs.hasRole("itil") && !gs.hasRole("sn_incident_read") && gs.isInteractive()) {
// if member then do this else use the OOB logic
if (gs.getUser().isMemberOf('CFS-CFSEdge-SUP') && !gs.hasRole('itil')) {
var u = gs.getUserID();
current.addQuery("caller_id", u).addOrCondition("opened_by", u).addOrCondition("assignment_group.name", "CFS-CFSEdge-SUP");
} else {
//Do NOT restrict Incidents if SPM premium plugin is active AND user has the service_viewer role.
if (GlidePluginManager.isActive('com.snc.spm') && gs.hasRole('service_viewer'))
return;
if (GlidePluginManager.isActive('sn_fsm_itsm_mng') && gs.hasRole('wm_ext_agent'))
return;
// STRY52118544: ham_user is added to support incident read for reporting on HAM store app
if (GlidePluginManager.isActive('com.sn_hamp') && gs.hasRole('sn_hamp.ham_user')) {
return;
}
// DEF0330091: Allow query on OT Incident with sn_ot_incident_read role
if (GlidePluginManager.isActive('com.sn_ot_inc_mgmt') && gs.hasRole("sn_ot_incident_read"))
return;
// Responders should be able to access all incidents
if (gs.hasRole("sn_sow_srm.srm_responder")) {
return;
}
var u = gs.getUserID();
current.addQuery("caller_id", u).addOrCondition("opened_by", u).addOrCondition("watch_list", "CONTAINS", u);
}
}
//}
Tested :-
I have impersnated with the user who don't have ITIL access .
user who raised the incident, can able to view incident which is assigned edge group .
Now , edge grp members are not able to see the incidents , and ITIL users can able to view . which is incorrect
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-28-2025 09:10 PM
I believe I provided you the right direction for your requirement.
All agents who work on incident have itil role so you need to ensure you handle all the cases
1) if logged in user is ITIL and not member of that group
2) logged in user is ITIL and member of that group
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader