Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Need help in Business Rule

nameisnani
Mega Sage

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

 

nameisnani_0-1738048362746.png

 

nameisnani_1-1738048429718.png

 

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 , 

 

nameisnani_2-1738048705560.png

 

 can anyone please modify my script . so that end user can see their incident , 

21 REPLIES 21

@nameisnani 

then update as this in OOB query BR "incident query"

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);
        }
    }
}

Something like this in OOB Table level READ ACL

https://instanceName.service-now.com/nav_to.do?uri=sys_security_acl.do?sys_id=7da3bda1c0a801667dc88c1e9527f776

        if (gs.getUser().isMemberOf('CFS-CFSEdge-SUP')) {
            current.opened_by == gs.getUserID() || current.caller_id == gs.getUserID() || current.assignment_group.name == 'CFS-CFSEdge-SUP';
        } else {
            current.opened_by == gs.getUserID() || current.caller_id == gs.getUserID() || current.watch_list.indexOf(gs.getUserID()) > -1;
        }

AnkurBawiskar_0-1738056160128.png

 

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi @Ankur Bawiskar 

 

showing warning 

 

nameisnani_0-1738118558930.png

 

Hi @Ankur Bawiskar 

 

I have modified the ACL - Still other users are able to view incidents belongs to 

CFS-CFSEdge-SUP

@nameisnani 

please share your query BR script and the table level READ ACL script.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@Ankur Bawiskar 

 

I have tested now , ITIL users are able to view incidents which belongs to 

CFS-CFSEdge-SUP

 

 

it should restrict for itil users also . 

 

could you please provide me the updated script for this .