Assign to me button not working when field is mandatory
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2023 08:41 AM
Hi community!
We have created an assign to me button with the following code:
assignToMe();
function assignToMe() {
if (current.assignment_group.nil()) {
var memberGroups = new global.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;
}
if (memberGroups.length == 1)
current.assignment_group = memberGroups[0];
}
current.assigned_to = gs.getUserID();
current.update();
action.setRedirectURL(current);
}
The problem we have is that when the field "Assigned to" is mandatory the UI action fails and we get the error message "he following mandatory fields are not filled in: Assigned to".
It's like the UI action does not populate the field and then save...
Can you please assist?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2023 09:00 AM
Hi @Elisa Mena,
Can you check, Is assigned/logged in user is part of multiple groups?
Thanks,
Sagar Pagar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2023 10:32 AM
Elisa,
What is the purpose of the Assignment Group check? Look into Assignment Rules....
I recommend removing the stuff about Assignment Groups...
You're declaring your memberGroups variable under an if statement that only runs when there is no assignment group...That should never or rarely happen
You then run an if against the memberGroups variable but it's not going to be defined unless there is no assignment group. You're most likely erroring with memberGroups not defined when it hits that if statement and never getting to set the assigned_to field.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2025 05:50 AM
Hi @Elisa Mena ,
I'm facing the same issue, when the assigned to is mandatory and I click on the "Assing to me" button, the script is not executed and I only get the error message related to the mandatory assigned to.
Did you find a solution for this ?
Thank you