Restrict the access for creating P!/P2 incident for some groups

Yakshitha
Tera Contributor

I have requirement  that only servicedesk and incident management team should be able to create P1/P2 incidents.

So I have created the display business rule and onchange client script for priority field. But now the servicedesk people also not able to create P1 incidents. the issue is the alert popup will appear for everyone irrespective of their group.

Screenshot 2023-06-16 130712.png

 

Screenshot 2023-06-16 130320.png

 

2 REPLIES 2

Riya Verma
Kilo Sage
Kilo Sage

Hi @Yakshitha ,

 

Hope you are doing great.

To address this, we can modify the existing scripts and add additional logic to achieve the desired behavior.

  1. Display Business Rule: The display business rule controls the visibility of the priority field.

 

(function executeRule(current, previous /* Add any other parameters */) {
  var group = gs.getUser().getMyGroups(); 

  if (!(group.contains('Service Desk') || group.contains('Incident Management'))) {
    current.priority.setDisplayValue('3'); 
  }
})(current, previous /* Add any other parameters */);
​

 

  • OnChange Client Script:

 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
  if (isLoading || newValue == '') {
    return;
  }

  var group = g_user.getMyGroups(); // Get the groups of the currently logged-in user

  if (!(group.contains('Service Desk') || group.contains('Incident Management'))) {
    if (newValue == 1 || newValue == 2) {
      g_form.setValue('priority', '3'); // Set priority to P3 for non-authorized users
      alert('Only the Service Desk and Incident Management teams can select P1/P2 priorities.'); // Display an alert message
    }
  }
}
​

 

 

Please mark the appropriate response as correct answer and helpful, This may help other community users to follow correct solution.
Regards,
Riya Verma

Hi Riya,

 

Getting below error.

 

Screenshot 2023-06-16 185512.png