How to undo the mandatory property in form

Hi All,

In SalesCreateOrder form, there are fieldA and fieldB which are from SalesTable and these fields are mandatory at table level. I want to set FieldA and FieldB as non-mandatory based on some condition. I have written the code in ‘SalesPoolId’ modified method. Ax is executing the code yet the fieldA and fieldB are displayed as mandatory.

I have used following piece of code.

if (!SalesPool::find(salesTable.SalesPoolId).cnlWFJOrder)












How can I make those fields as non-mandatory ?

Thanks in advance.

By setting fields as mandatory on table level, you claim something like “any record in this table makes no sense without these fields, therefore is forbidden to save it”. If it is still true, you try to create what your DB setup consider as invalid and it hopefully stopped you.

But if you think that it is valid for some records not to contain values in such fields, set them as non-mandatory on table level and implement some logic to verify that the value is set to records that still requires some. The most important place is in validateWrite(), but you can also conditionally set form controls as mandatory etc.

Thanks Martin, I have set fields as non-mandatory on table level and have given conditions to validate in validateWrite() method.