Make dialog field mandatory BOMCreateDialog

Hi,

Environment: AX 2012

i have this class BOMCreateDialog which has 5 fields or less, i want to make site and name mandatory, setting it to

FieldStringControl . mandatory(true) doesnt help - pressing ok button still turns off dialog, i only get red underline, the class doesnt extend runBase or anything else, how to make 2 fields mandatory there ? Description and Site.

There already seem to be a validation for site in BOMCreateDialog.promptCreateBOMDialog(). Check it out there.

There’s nothing that stops OK button to kill dialog form there, only some kind of strange validation for multi-site which i dont know what it is becouse i dont see its warning throwed becouse if you enter site which doesnt exist anyway - there’s edt validation which you see for non existing site in InventDim, and it does stop dialog from being killed, i tryed to use this registerOverrideMethod with validate method on FormStringControl, but for some reason this way works only for making lookup fields, validation doesnt respond on it, there is a way to all this with RunBaseBatch but for BOMCreateDialog 2 mandatory fields it looks like an overkill to me, More detailed case is here:

Site will be mandatory on form DS level, BOM Name on table level, so it both becomes mandatory on form grid level → but there’s a dialog in which you can enter these two too instead of form new grid button, so it has to be mandatory in dialog too:

i tried:

  1. mandatory(true) and mandatory_RU(true) - doesnt work
  2. RunBaseBatch takes a lot of modifications or i dont know how to do it in optimized way
  3. promptCreateBOMDialog doesnt look like it would have anything that stops dialog from being killed by OK button
  4. registerOverrideMethod(methodStr(FormStringControl, validate)) → boolean validate() return false; doesnt respond.

most of the standard x++ dialogs in AX are deriving RunBaseBatch, but for some reason this BOMCreate is not

I will try using extends RunBaseBatch, but i wonder maybe is there an easier way just for stopping OK button from killing dialog form… >.>;

Of course there is nothing that would prevent OK button to close the dialog. That’s how the Dialog class works. All you can do is open the dialog again.

RunBase is a different case, because developers of this framework added extra handling to Dialog form, method closeOk().

Simply put - what you want isn’t supported by the API you’re currently using. Either use a workaround or use something that supports the requirement. You can reopen the dialog after validation, use a RunBase class, implement and display your own form, add features to the Dialog class (or a new sub-class) and so on.

By the way, you can’t say that dialogs are deriving from RunBaseBatch. Generating and showing dialogs is just one part of what RunBaseBatch classes do (batch execution, serialization etc.) and they use other objects to actually show the dialog - most importantly DialogRunBase and Dialog classes and Dialog form. These objects are independent; they don’t derive from RunBaseBatch in any way, and using dialogs outside the RunBase framework is a completely valid scenario. You’ll use such a dialog - obviously - when you need a dialog but not RunBase.