Axaptapedia is now maintained by AgileCadence For more information please click here.

Dialog

From Axaptapedia
Jump to: navigation, search

Dialoghirarchie.png

Dialog is a base class in Dynamics AX. Use the dialog class to create simple dialog forms at run time. Here is an example: <xpp> Dialog dialog; DialogField field;

dialog = new Dialog("My Dialog"); field = dialog.addField(typeId(EmplId)); // add EmplId field

dialog.run(); // show

if (dialog.closedOK()) {

   info(field.value());

} </xpp>

Dynamic dialog

Initiated by this newsgroup posting I've written a class that for dynamic dialogs. You provide a list with types, and the dialog will contain all necessary fields. Use the method parmFieldList() to get the field values. <xpp> /**

* Use this class to create a dialog with dynamic content.
*/

class CustomDialog extends Dialog {

 List fieldList; /* list of dynamically create dialog fields */
 /** 
  * The dialog will contain fields for all types in the typeList 
  * Field description is taken per default from the extended datatype
  */
 void new(List    typeList,
          Caption _caption = ,
          Object  _caller  = null,
          str     _parmstr = ,
          Form    _form    = new Form(formStr(Dialog))
          )
 {
   ListEnumerator enum;
   ;
   if(typeList == null) 
     error("List of types must not be null");
   super(_caption,_caller,_parmStr,_form);
   fieldList = new List(Types::Class);
   enum      = typeList.getEnumerator();
   while(enum.moveNext())
   {
     fieldList.addEnd(this.addField(enum.current()));
   }
 }
 
 /**
  * Use this method to get the values entered in the dialog
  * @return Reference to the fieldList if instantiated.
  */
 public List parmFieldList()
 {
   return fieldList;
 }

} </xpp>

The class is easy to use <xpp> static void testDynamicDialog(Args _args) {

 CustomDialog   diag;
 List           types = new List(Types::Integer); // typeId is an integer
 List           fields;
 ListEnumerator enum;
 DialogField    field;
 ;
 // the dialog shall contain fields for the following types
 types.addEnd(typeId(EmplId));
 types.addEnd(typeId(Itemid));
 types.addEnd(typeId(ProdId));
 types.addEnd(typeId(CustAccount));
 // crate and show
 diag = new CustomDialog(types,"Dynamic Dialog");
 diag.run();
 // show values in the Infolog
 fields = diag.parmFieldList();
 enum   = fields.getEnumerator();
 while(enum.moveNext())
 {
   field = enum.current();
   info(field.value());
 }

} </xpp>

See Also

Override Lookup on DialogField

Adding only one Dimension in Dialog

Dialog macro

3 Great Dialog Class Extensions