- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2025 08:45 AM
I have this script for UI Action Assign to me:
assignToMe(); function assignToMe() { if (!current.active || !current.assigned_to.canWrite()) { gs.addErrorMessage(gs.getMessage('You do not have permission to update assigned to')); return; } else if (!current.assignment_group.nil() && !gs.getUser().isMemberOf(current.assignment_group.toString())) { gs.addErrorMessage(gs.getMessage("Assigned to user {0} must be member of Assignment group {1}", [gs.getUserDisplayName(), current.assignment_group.getDisplayValue()])); return; } else if (current.assignment_group.nil()) { var memberGroups = new IncidentUtils().getMemberGroups(gs.getUserID(), 2); if (memberGroups.length > 1) { gs.addErrorMessage(gs.getMessage("Assigned to user {0} is member of multiple groups, please select one as Assignment group", [gs.getUserDisplayName()])); return; } else if (memberGroups.length == 1) current.assignment_group = memberGroups[0]; } action.setRedirectURL(current); current.assigned_to = gs.getUserID(); current.update(); }
The problem is when the user is part of multiple group the redirection is done on incident list and the message error is not on the incident form!
Can anyone help me for this please?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2025 08:49 AM
Hi @ahmed-24 ,
update your script like this and check
assignToMe();
function assignToMe() {
action.setRedirectURL(current);
if (!current.active || !current.assigned_to.canWrite()) {
gs.addErrorMessage(gs.getMessage('You do not have permission to update assigned to'));
return;
} else if (!current.assignment_group.nil() && !gs.getUser().isMemberOf(current.assignment_group.toString())) {
gs.addErrorMessage(gs.getMessage("Assigned to user {0} must be member of Assignment group {1}", [gs.getUserDisplayName(), current.assignment_group.getDisplayValue()]));
return;
} else if (current.assignment_group.nil()) {
var memberGroups = new IncidentUtils().getMemberGroups(gs.getUserID(), 2);
if (memberGroups.length > 1) {
gs.addErrorMessage(gs.getMessage("Assigned to user {0} is member of multiple groups, please select one as Assignment group", [gs.getUserDisplayName()]));
return;
} else if (memberGroups.length == 1)
current.assignment_group = memberGroups[0];
}
current.assigned_to = gs.getUserID();
current.update();
}
Please mark my answer as helpful/correct if it resolves your query.
Regards,
Chaitanya
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2025 08:49 AM
Hi @ahmed-24 ,
update your script like this and check
assignToMe();
function assignToMe() {
action.setRedirectURL(current);
if (!current.active || !current.assigned_to.canWrite()) {
gs.addErrorMessage(gs.getMessage('You do not have permission to update assigned to'));
return;
} else if (!current.assignment_group.nil() && !gs.getUser().isMemberOf(current.assignment_group.toString())) {
gs.addErrorMessage(gs.getMessage("Assigned to user {0} must be member of Assignment group {1}", [gs.getUserDisplayName(), current.assignment_group.getDisplayValue()]));
return;
} else if (current.assignment_group.nil()) {
var memberGroups = new IncidentUtils().getMemberGroups(gs.getUserID(), 2);
if (memberGroups.length > 1) {
gs.addErrorMessage(gs.getMessage("Assigned to user {0} is member of multiple groups, please select one as Assignment group", [gs.getUserDisplayName()]));
return;
} else if (memberGroups.length == 1)
current.assignment_group = memberGroups[0];
}
current.assigned_to = gs.getUserID();
current.update();
}
Please mark my answer as helpful/correct if it resolves your query.
Regards,
Chaitanya
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2025 09:01 AM
It's not working !! the record is lost when i click assign to me button
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2025 09:14 AM
Hi @ahmed-24
I have tested this and is working fine for me 🤔
could you please check again?
Please mark my answer as helpful/correct if it resolves your query.
Regards,
Chaitanya
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2025 12:07 AM
@Chaitanya ILCR did you check the box client tru on ui action form ?