Setting g_form.setMandatory to false not working on client script (backend form and portal)

kemmy1
Tera Guru

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


}

2 REPLIES 2

Basheer
Mega Sage

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 hit like button if my suggestion has helped you in any way.
Please mark correct if my response has solved your query.

Cheers,
Mohammed Basheer Ahmed.

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.