Setting g_form.setMandatory to false not working on client script (backend form and portal)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-24-2023 11:12 AM - edited 01-24-2023 11:19 AM
I have a client script that sets a field to mandatory (true) onLoad.
If the status is "Draft" I want this field to not be mandatory onSubmit:
function onSubmit() {
var getStatus = g_form.getValue('status');
if(getStatus == 'Draft'){
g_form.setMandatory('field', false);
// I've tried this as well: g_form.checkMandatory = false;
}
Am I doing something wrong?
Lisa
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-24-2023 12:07 PM
You need to write an UI Policy to make it not mandatory when the status is draft. You can't do it in onSubmit
Please mark correct if my response has solved your query.
Cheers,
Mohammed Basheer Ahmed.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-24-2023 01:27 PM
I'm sorry, I should have been a little more clear. I'd like the fields to still "look" like they are mandatory, but if the status is Draft, upon submit, those fields are not mandatory.