Make field mandatory only by clicking a ui action button
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-27-2023 07:07 AM
Hi everybody! I would like to make a field in my form mandatory only if a user of a group is trying to click a specific ui action button. How could I do it? With some script? Which one?
I've tried with policy and br, but it make the field mandatory for all the other ui buttons in the form in that particular state.
Thanxs
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-27-2023 07:13 AM - edited 01-27-2023 07:14 AM
In the UI Action, put current.setMandatory(Field Name, true);
Hope this will resolve your issue.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-27-2023 08:17 AM
when I put it in the ui action it doesn't work, when I click that button I have a script on that works, so maybe I've to put it first of the script running?
I've to make the field mandatory before this script run, so how could I put it in the ui action? Here the script in my ui action button:

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-27-2023 07:19 AM
Sounds like the button needs to run a client script and it needs to do
g_form.setMandatory();
If you still need to run part of the client script for the button on the server side then you can do something like this
function CLIENTFUNCTION() {
//Put Client Code Here
gsftSubmit(null, g_form.getFormElement(), 'UI_ACTION_NAME');
}
if (typeof window == 'undefined')
serverSideCodeToRun();
function serverSideCodeToRun() {
//Put Server side code hear.
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 weeks ago
Hi @Alessia Russo
Follow these steps to make field mandatory on click of UI Action :-
UI Action settings
Client: ✅ Checked (so it can run on the client side)
Action name: mark_mandatory
Form button: ✅ Checked
In the Script section :- Just use this line of code inside the function
g_form.setMandatory('field_name', true); // Write your original field name in replace of field_namePlease accept my answer and mark as helpful/correct if it resolves your query.
Regards,
Nitish