- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2024 05:35 AM
Hi Team,
I'm Trying to stop user resolving the incident which contains priority is P1/P2. its working but not meeting our Test Cases:
1)if priority is p1/p2 then it allow only "major incident management team" to resolve the incident.
2) Allow other users to update the incident or assignee to "Major incident management team to resolve the incident
currently below Before BR not allowing any user to raise a p1/p2 incidents or update anything when priority is p1/p2.
let me know if any changes required in the BR or its a correct way to write the Before BR for this request.
1)When to Run
2)Script:
let me if any error in my code. only "Major incident management" group allow to resolve the priory P1/P2 incidents
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2024 06:21 AM - edited 03-19-2024 06:22 AM
Hi @nani1
Can you replace yours with the following code and try-
if (current.assignment_group != 'Incident Management Group') {
if (current.state == '6') {
current.state = previous.state; // Rollback state change
current.setAbortAction(true);
current.addErrorMessage("Only the 'Incident Management Group' can resolve incidents with priority P1 or P2.");
}
}
Please mark my answer helpful and correct.
Regards,
Amit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2024 10:14 PM
Hi @nani1
Its strange as the above is working for me. There might be some other validations which is conflicting with this.
You can try achieving it with onChange client script-
- Type: onChange
- Target Field: state.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue === '') {
return;
}
var stateValue = '6';
var groupSysId = 'SPECIFIC_GROUP_SYS_ID';
var groupField = 'assignment_group';
if (newValue === stateValue && g_form.getValue(groupField) !== groupSysId) {
g_form.setValue('state', oldValue);
alert("Only the 'Incident Management Group' can resolve incidents with priority P1 or P2.");
}
}
Regards,
Amit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2024 11:57 PM
will try and let you know
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2024 12:30 AM
Hi,
Below script is working now, actually i pick the wrong sys id of a group.
if (current.assignment_group != 'SYS_ID OF GROUP') { if (current.state == '6') { current.state = previous.state; // Rollback state change current.setAbortAction(true); current.addErrorMessage("Only the 'Incident Management Group' can resolve incidents with priority P1 or P2."); } }
I need to restrict the same in list view, but in ACL how can i add condition's?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2024 12:32 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-04-2024 04:07 AM
How can we achieve same thing via client script?
I tried below but did not work -
Script include -
var CheckUserGroup = Class.create();
CheckUserGroup.prototype = {
initialize: function() {
},
checkMembership: function(userId, groupName) {
var gr = new GlideRecord('sys_user_grmember');
gr.addQuery('user', userId);
gr.addQuery('group.name', groupName);
gr.query();
return gr.hasNext().toString();
},
type: 'CheckUserGroup'
};
client script -
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
if (newValue == 9) {
var userId = g_user.userID;
var ga = new GlideAjax('CheckUserGroup');
ga.addParam('sys_id', userId);
ga.addParam('group_name', 'Incident and Problem Managers');
ga.addParam('sysparm_name', 'checkMembership');
ga.getXMLAnswer(function(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
if (answer == 'false') {
g_form.setValue('state', oldValue);
g_form.addErrorMessage('You are not authorized to reject this problem.');
}
});
}
}