access for rasing p1 and p2 tickets

govardhantv
Kilo Contributor

HI All,

I have requirment that end user should not raise p1and p2 tickets ...user with these condition 2 and 3,should be able to raise the p1 and p2,if user is having only encripition_role then he should not raise p1 or p2.

requirments:

conditions1:encripition_role...cannot raise p1 and p2 tickets.

condition2:encription_role+itsd can raise p1 and p2 tickets

condition3:encripition_role+admin can raise p1andp2 tickets

i have tried all possible ways to achevie this ...but no luck..i am new to servicenow ..can i get some help on this .

Thanks & Regards

Govardhan.

9 REPLIES 9

anurag92
Kilo Sage

So for other 2, it would be:


if((p== '1' || p== '2'))


{


if(g_user.hasRoleExactly('encripition_role'))


alert("You can't submit a P1/P2 incident");



else if(!(g_user.hasRole('encripition_role') && (g_user.hasRole('admin') || g_user.hasRole('itsd')))) //Checking here if user   has 2 roles


alert("You can't submit a P1/P2 incident");



}


Hi Anurag,


Can i write all this code in one client script ..and i am writing it on change client script and filed is priority...is this is correct or i have change some thing here ...


anurag92
Kilo Sage

Yes, you can add this code in a client script, with onChange on Priority field. You might face some errors at the first go, let me know if any.


Hi Anurag,





i have written script like this ,can you check and let me know whether i have done some thing wrong .





function onChange(control, oldValue, newValue, isLoading, isTemplate) {


  if (isLoading || newValue === '') {


  return;


  }


  if(g_user.hasRole('encripition_role'))


  {



  if(newValue == '1' || newValue == '2')


  {


  alert('A Sev1/Sev2 incident can only be raised by a user having Role Encryption and ITIL');


  g_form.setValue('urgency', 3);


  g_form.setValue('impact', 3);


  g_form.setValue('priority', oldValue);


  }


  }



  else if(!(g_user.hasRole('encripition_role') && (g_user.hasRole('admin') || (g_user.hasRole('SD_Agent') && (g_user.hasRole('encripition_role')))))) //Checking here if user   has 2 roles


alert("You can submit a P1/P2 incident");




}


anurag92
Kilo Sage

Yes Gova,


just update g_user.hasRole('encripition_role') as g_user.hasRoleExactly('encripition_role')



and in else part



  else if((g_user.hasRole('encripition_role') && (g_user.hasRole('admin') || (g_user.hasRole('SD_Agent') && (g_user.hasRole('encripition_role')))