Resolve Incident Button Issue

Cupcake
Mega Guru

I have found an issue with displaying the Resolve Incident button (UI Action) on some incidents and not others both having the same state and I don't understand what the difference is.

So I have 

a) ACLs in place that state that the State and other fields of an incident cannot be changed if that incident is assigned to specific assignment groups are if you are NOT a member of that group.

b) I also have conditions in the UI Action as follows:

((current.incident_state != 7 && current.incident_state != 6) || (current.state != 7 && current.state != 6))&& (gs.hasRole("itil") || gs.hasRole("itil_admin") || current.caller_id == gs.getUserID()) && new ResButton().checkIncTask()

But I don't understand why the Resolve Incident button is some incidents and not others. See screenshots below. I am going to keep looking to see if I can figure this out.

Any assistance would be much appreciated.

 

1 ACCEPTED SOLUTION

You are very welcome. Here is the updated code.

var ResButton = Class.create();
ResButton.prototype = Object.extendsObject(AbstractAjaxProcessor, {
checkIncTask: function(){
var incTask = new GlideRecord("u_inc_task");
incTask.addQuery("u_inc", current.sys_id);
incTask.addQuery("active", true);
incTask.query();
if(incTask.next()){
return false;
}
else if(current.assignment_group.getDisplayValue() == 'PASS ASSIGNMENT GROUP NAME HERE')
{
return false;
}
else{
return true;
}
},


type: 'ResButton'
})

 

-Pradeep Sharma

View solution in original post

14 REPLIES 14

This is Awesome. I learned alot today.

Thank you again.

Karen.

You are very welcome Kbrownibx. Thanks for participating in the community!

 

-Pradeep Sharma

Good day to you Pradeep. I wanted to reach back to you about this issue. It appears to be working for the most part, but while I was on vacation the customer tested and found another issue.

So we have two assignment groups:

a) Service Desk - "SD Assignment Group", and

b) Business Area - "BA Assignment Group"

No one should be able to see the resolve incident button for any incident assigned to the Service Desk unless you are a member of that group. And the same for the business area - if an incident is assigned to the Business Area you should NOT see the resolve incident button unless you are a member of the group.

However, if there is any other incident assigned to any other group other than the two listed above it is okay to see the Resolve Incident button.

How can I resolve this with the script that you provided and also my concerns is looking into the future what if other groups want the same functionality? Won't this script get extremely complex?

HI @Kbrownobx,

 

You can adjust the script as

 

var ResButton = Class.create();
ResButton.prototype = Object.extendsObject(AbstractAjaxProcessor, {
checkIncTask: function(){
var incTask = new GlideRecord("u_inc_task");
incTask.addQuery("u_inc", current.sys_id);
incTask.addQuery("active", true);
incTask.query();
if(incTask.next()){
return false;
}

else if(gs.getUser().isMemberOf('PASS  Service Desk GROUP NAME HERE') || gs.getUser().isMemberOf('PASS Business Area GROUP NAME HERE'))

{

return true;

}
else if(current.assignment_group.getDisplayValue() == 'PASS ASSIGNMENT GROUP NAME HERE')
{
return false;
}
else{
return true;
}
},


type: 'ResButton'
})

 

Also, find my comments below 

However, if there is any other incident assigned to any other group other than the two listed above it is okay to see the Resolve Incident button.

[Pradeep Sharma]: Earlier you have mentioned i.e "If there are no active incident tasks and the incident is assigned to a specific assignment group then I also do not want the Resolve Incident button to show." Is this requirement changed now? If yes, then remove the last else if the line from the above code.

 

How can I resolve this with the script that you provided and also my concerns is looking into the future what if other groups want the same functionality? Won't this script get extremely complex?

[Pradeep Sharma]: To make it more dynamic, you can create a system property to store the group names and then use the same property in the script to drive the logic to show/hide the button.

 

-Pradeep Sharma

 

 

Thank you Pradeep. I had to add a little more to the code but finally got it working. And the requirements changed again.

 

var ResButton = Class.create();
ResButton.prototype = Object.extendsObject(AbstractAjaxProcessor, {
checkIncTask: function(){
var incTask = new GlideRecord("u_inc_task");
incTask.addQuery("u_inc", current.sys_id);
incTask.addQuery("active", true);
incTask.query();
if(incTask.next()){
return false;
}


else if(current.assignment_group.getDisplayValue() == ('Business Group Name') && gs.getUser().isMemberOf('Business Group Name') || (current.assignment_group.getDisplayValue() == ('SD Group Name') && gs.getUser().isMemberOf('SD Group Name') || current.caller_id == gs.getUserID()))


{


return true;


}
else if(current.assignment_group.getDisplayValue() == 'Business Group Name' || (current.assignment_group.getDisplayValue() == 'Service Desk Group Name'))
{
return false;
}
else {
return true;
}
},


type: 'ResButton'
});