- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-21-2017 02:13 AM
How we can Restrict certain groups in ServiceNow to only P1 and P2 incidents can assigned to particular group
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-24-2017 02:11 AM
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:
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:
For example I have created a Property called "get_groups" where I have defined Sys Id of the multiple Assignment Groups as shown below:
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);
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
Regards,
Shloke
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-21-2017 10:13 AM
Hi,
You can do this with the help of a Display Business Rule and an On Change Client Script on the Incident Table as explained below:
1) Create a Display Business Rule on the Incident Table as shown below:
2) Once the Display BR is created, create an On Change Client Script on the Incident Table on Priority field as mentioned below:
Script:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue == '') {
return;
}
if(!g_form.isNewRecord())
{
if((newValue == 1 || newValue == 2) && !(g_scratchpad.grp1 || g_scratchpad.grp2)) //Where 1 & 2 are Priority Values for Critical and High
{
alert('A Priority 1 & Priority 2 incident can only be raised by a member of the Group 1 and Group 2');
g_form.setValue('urgency', 3);
g_form.setValue('impact', 3);
g_form.setValue('priority', oldValue);
}
}
}
Hope this helps.Mark the answer as correct/helpful based on impact.
Regards,
Shloke
Regards,
Shloke
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-21-2017 10:25 AM
I'm confused... I thought Vivekanand wanted to restrict assignment of P1/2 to specific groups, not restrict creation of P1/2 incidents to only those groups.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-24-2017 01:12 AM
Hi Dave,
Yes Dave your are correct.
I wanted to restrict assignment of P1/2 to specific groups.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-24-2017 02:11 AM
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:
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:
For example I have created a Property called "get_groups" where I have defined Sys Id of the multiple Assignment Groups as shown below:
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);
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
Regards,
Shloke
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-24-2017 08:20 AM