Prevent creation of P1 and P2 incident ticket based on role

Service Manager
Kilo Guru

Hi All,

I need help to create/update the P1 and P2 incidents based on roles.

P1 and P2 incidents are created and updated by users who has ITIL_admin role only

P1 and P2 incidents are updated by used who has agent_admin role only.

FYI - I tired with onchange scirpt and BR but no luck

Thanks

1 ACCEPTED SOLUTION

Allen Andreas
Administrator
Administrator

Hi,

In the future, please share what you've tried. You telling is "no luck" doesn't help us help you learn and correct what you did (you could have been close?)

You can create a before insert AND update business rule on the incident table that if the priority is P1 or P2 it does the check to see if the user is allowed to create and/or update such as with script:

if (current.operation() == 'insert' && !gs.hasRole('itil_admin')) {
gs.addInfoMessage("Only users with the itil_admin role can create an Incident with a Priority of P1 or P2");
current.setAbortAction(true);
} else if (current.operation() == 'update' && !gs.hasRole('itil_admin,agent_admin')) {
gs.addInfoMessage("Only users with the itil_admin or agent_admin role can update an Incident with a Priority of P1 or P2");
current.setAbortAction(true);
}

Ensure you set the condition on this business rule to priority = P1 or priority = P2.

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

View solution in original post

2 REPLIES 2

Allen Andreas
Administrator
Administrator

Hi,

In the future, please share what you've tried. You telling is "no luck" doesn't help us help you learn and correct what you did (you could have been close?)

You can create a before insert AND update business rule on the incident table that if the priority is P1 or P2 it does the check to see if the user is allowed to create and/or update such as with script:

if (current.operation() == 'insert' && !gs.hasRole('itil_admin')) {
gs.addInfoMessage("Only users with the itil_admin role can create an Incident with a Priority of P1 or P2");
current.setAbortAction(true);
} else if (current.operation() == 'update' && !gs.hasRole('itil_admin,agent_admin')) {
gs.addInfoMessage("Only users with the itil_admin or agent_admin role can update an Incident with a Priority of P1 or P2");
current.setAbortAction(true);
}

Ensure you set the condition on this business rule to priority = P1 or priority = P2.

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

I appreciate your help!

I tried to accomplish the requirement via client script based on initial requirements

later on they added another group

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
   if (isLoading || newValue === '') {
      return;
   }
  //if(!g_form.isNewRecord())
//{
	
var oldUrgency = '';
	var oldImpact = '';
	
	//get the current record values from the incident table
	var incNum = g_form.getValue('number');
	var gr = new GlideRecord('incident');
	gr.addQuery('number', incNum);
	gr.query();
	while(gr.next()) {
		//alert(gr.number);
		oldUrgency = gr.urgency;
		oldImpact = gr.impact;
	}	
	
 if((newValue == 1 || newValue == 2) && !g_user.hasRole('itil_admin'))
  {
			
  alert('test 123');
	jslog ('test123');
  g_form.setValue('urgency', oldUrgency);
  g_form.setValue('impact', oldImpact);
  g_form.setValue('priority', oldValue);
  return false;
}
------------------------------------- xI tired with new codex---------------
	else if((newValue == 1 || newValue == 2) && !g_user.hasRole('agent_admin'))
  {
			
  alert(' Dont have access to create records'); // only able to update
	jslog ('test45');
//   g_form.setValue('urgency', oldUrgency);
//   return false;
}
	
 // }
   
}

 

thanks