- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2016 04:11 AM
Hi All;
In change form we have lots of mandatory fields depends on the state/type of change. When user need to cancel the change he/she not to ask to fill the mandatory fields depends in which state he/she cancelling.
I can use g_form.setMandatory("FiledName" , false). But again I need to write code for all the mandatory fields (its around 30+) .
Is there any other way to remove/disable all the mandatory fields using single line code.
Thanks in Advance.
Balaji Prusty.
Solved! Go to Solution.
- 11,861 Views
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-22-2016 03:50 AM
I am not getting the Close the loop / Answered under Action....I was looking for this option.
All my previous threads are still open due to this...not sure what/whom need to contact to get this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2016 06:02 AM
Balaji,
Use thefunction above to ignore all o them, force to make the close note mandatory with something like close_note.mandatory = true.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2016 07:49 AM
Hi Zic;
It Not works if put like this.
g_form.checkMandatory = false; |
close_notes.mandatory = true;

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-13-2018 07:18 AM
For me, it doesn't seem like anyone understands your question. You asked, "Is there any other way to remove/disable all the mandatory fields using single line code."
Well, maybe not "one line", but one simple for() loop.
for (var i = 0; i < g_form.elements.length; i++)
{
var el = g_form.elements[i];
var fieldName = el.fieldName;
g_form.setMandatory(fieldName, false);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-20-2018 01:33 AM
Hi Davidd, this did not work for me.
I also tried to disable specific fields like g_form.setMandatory(category, false), but that appears to do nothing.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2021 09:19 AM
You can try below code on UI action. It will work.
function callClientScript() {
//Client Script
var arr = g_form.getMissingFields();
for (var x = 0; x < arr.length; x++) {
g_form.setMandatory(arr[x], false);
alert("Following fields are set Non Mandatory: " + arr[x]);
}
gsftSubmit(null, g_form.getFormElement(), 'update_to_p1'); // UI action name
}
if (typeof window == 'undefined')
callServerScript();
function serverScript() {
// Server Script
current.update();
action.setRedirectURL(current);
}
Please mark answer helpful if it helped.
Regards
Pawan K Singh