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

Ankur Bawiskar
Tera Patron
Tera Patron

@nameisnani 

can you explain your business requirement here?

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

amitshishod
Tera Guru

Hello @nameisnani ,
Try using below script.

 current.addEncodedQuery("^assigned_to=" + gs.getUserID() + "^ORassignment_groupDYNAMICd6435e965f510100a9ad2572f2b47744" + "^ORcaller_id=" + gs.getUserID()); //after dynamic enter sys_id of your group(ideally we should not use hard code value but please first check with this.If it work then We can change it.)

If my response helped please mark it correct and helpful.

@amitshishod  

 

Hi Amit ,

 

could you please provide me the steps , it is confusing .

if possible plz provide updated script .

@nameisnani , for now please try using the script I gave to you and crosscheck.
First remove condition : 

condition - !gs.getUser().isMemberOf('CFS-CFSEdge-SUP')

Then use this script below

current.addEncodedQuery("^assigned_to=" + gs.getUserID() + "^ORassignment_groupDYNAMICd6435e965f510100a9ad2572f2b47744" + "^ORcaller_id=" + gs.getUserID());

//Here in query after ORassignment_groupDYNAMIC you need to paste sys_id of your group and then after that you can crosscheck it.

Just paste the code inside script and only change sys_id(enter your sys_id and mentioned above) and it will work.

If my response helped please mark it correct and helpful.


 

 

@amitshishod 

 

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

 

 

where i need to update ? your script