How we can Restrict certain groups in ServiceNow to only P1 and P2 incidents can assigned to particular group

kulkarnivivekn
Tera Contributor

How we can Restrict certain groups in ServiceNow to only P1 and P2 incidents can assigned to particular group

1 ACCEPTED SOLUTION

Thanks Vivekanand and Dave for clarifying the Requirement.



You can write an On Submit Client Script to restrict the same as shown below for a particular Group:



find_real_file.png




So the above Script Restricts the User from Submitting the High Priority Ticket to the Cab Approval Group for example whose Sys Id has been mentioned in the Screen shot above.



Similarly if there are few Assignment Groups you cna give an OR condition in the Script above in line Number 7 as mentioned below:



if(group =='b85d44954a3623120004689b2d5dd60a' || group == 'a715cd759f2002002920bde8132e7018')




Another Scenario can be where you have Multiple Groups for which you want to check the Validation then instead of using multiple Sys id's directly in a Client Script you can create a System Property and define your Assignment Group Sys Id in the Property and can use them multiple times using a Server Side Script to have the same Validation as explained Below:



Step 1:



Create A System Property by typing "sys_properties.list" from Application Navigator Search and click on New Button as shown below:



find_real_file.png



For example I have created a Property called "get_groups" where I have defined Sys Id of the multiple Assignment Groups as shown below:



find_real_file.png



Step 2:



Once the System Property has been defined, Create a Before Insert/Update Business Rule on the incident Table with Conditions as Priority is One of Critical or High and as per   the script below:



Script:



(function executeRule(current, previous /*null when async*/) {



  // Add your code here


  var grp1 = [];


  var grp =gs.getProperty('get_groups');


  grp1 =grp.split(',');



  for(var k=0; k < grp1.length; k++)


  {


  var gr = new GlideRecord('incident');


  gr.addQuery('sys_id',current.sys_id);


  gr.addQuery('assignment_group',grp1[k]);


  gr.query();


  if(gr.next())


  {


  gs.addInfoMessage('Invalid Submission for Priority 1 and Priority 2 Tickets for the Assignment Group selected');


  current.setAbortAction(true);



  }


  }



  })(current, previous);




find_real_file.png



find_real_file.png





Have tested and is working for me on my Personal Instance. Kindly test the same from your end too.



Hope this helps.Mark the answer as correct/helpful based on impact.



Regards,


Shloke


Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

View solution in original post

12 REPLIES 12

Dave Smith1
ServiceNow Employee
ServiceNow Employee

Not clear about the issue... do you mean that P1 and P2 incidents can only be assigned to specific groups, or do you mean only certain groups can assign P1/P2 incidents?


Hi Dave,



Thank you for replying.


I mean that P1 and P2 incidents can only be assigned to specific groups for example say "cccc" group and P3 or P4 ticket should not allow user to assigned to that particular group(CCCC)



Please let me know the script for this.


Okay... sounds like a Reference Qualifier is what you need.   That should be able to restrict the list of groups available in the assignment in the situations where the incident is a P1/P2.


vinitha3
Tera Guru

Use Script include and client script to do that.


You need to create a data look up for that and set assignment rules.



Data lookup definitions fields



Script includes



Use script includes



Thanks,


Vinitha.K