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

Try this in client script:


var p =g_form.getValue('priority');


if(g_user.hasRoleExactly('encripition_role') && (p== '1' || p== '2')



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


Hi Anurag,



we have three conditions here,can we wirte other two conditions in the same script ..if yes can you help me with it


Try below


var p =g_form.getValue('priority');


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


{


if(!(g_user.hasRole('admin') || g_user.hasRole('itsd')))


{


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


return false;


}


}



Mark Correct if it solved your issue or hit Like and Helpful if you find my response worthy.





shloke04
Kilo Patron

Hi,



Write an On Change Client Script on the Incident table with Field Name on "Priority" as mentioned below:



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


  }


  }



  //Type appropriate comment here, and begin script below



}


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