- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2023 05:25 AM
Hi ,
Good day to all,
I have requirement On Ui action . I have created a Ui Action Button " MyAssignmentgroup " and when i clicked on it worknotes should be mandatory and after filling the worknotes and again when i clicked on " MyAssignmentgroup " button then assignment group should be autopopulated to group "X"
Please find the attached screenshot and script i have written . Kindly Please let me now if any modifications has to be done.
Script :
onclick();
function onclick() {
g_form.setmandatory("work_notes");
gsftSubmit(null, g_from.getFormElement(), "MyAssignmentGroup");
}
if (typeof Window = "undefined")
setRedirect();
function setRedirect() {
current.update();
action.setRedirectURL(current);
}
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2023 06:35 AM
As far as I can see, it is now exactly the same as I have tested.
What exactly is not working? Just to make sure, the worknotes are on the form view? Otherwise it cannot be set mandatory.
Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2023 07:20 AM
Hi @sushma9
It was not an update set, its the UI Action. So should be visible in your incident form now.
Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2023 07:32 AM
It was the UI Action itself, not an update set. Take a look in your incident form. The UI Action is already there.
Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2023 08:11 AM
Hi Peter,
Thanks' for Your Support
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2023 05:57 AM
check if value is empty then only make mandatory
function onclick() {
if(g_form.getValue('work_notes') == ''){
g_form.setMandatory("work_notes", true);
return false;
}
gsftSubmit(null, g_from.getFormElement(), "MyAssignmentGroup");
}
if (typeof window == "undefined")
setRedirect();
function setRedirect() {
current.assignment_group = 'GroupSysIdHere';
current.update();
action.setRedirectURL(current);
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2023 06:01 AM
@Ankur Bawiskar
I saw what you just did... you missed the same g_from as I did 😉
Apart from that, it is redundant to check for the filled field. Since ServiceNow already checks if a mandatory field is filled, it is unneeded in this example.
Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2023 06:20 AM
Hi Ankur,
Thanks for your response. I tried with above provided code but its not working .Please find the attached screen shots.