Tuesday, January 11, 2011

Adding a field on dialog by addfield() method, when the type of EDT is known at run time, in Dynamics AX 2009

Possible situations when:

1.       EDT type is fixed and is known at design time.

public Object dialog()
{
            DialogRunbase       dialog = super();
;
            dlgTransDate                   = dialog.addField(typeid(CustAccount));

            return dialog;

}
       
         
2.     EDT Name is known in some situation.

public Object dialog()
{
    DialogRunbase dialog;
    Str                  edtName = “CustAccount”;
    ;
    dialog      = super();
    dialog.addField(new sysDictType(new Dictionary().typeName2Id(edtName)).extendedTypeId());
    return dialog;
}

3.     EDT Name is not known at design time, but is known at Run time from a table field.
public Object dialog()
{
    DialogRunbase           dialog;
    str                            edtName;
    dictField                    dictField;
    ;
    dialog            = super();
    dictField         = new DictField(tablenum(CustTable),fieldnum(CustTable, AccountNum));
    edtName       = extendedTypeId2name(dictField.typeId());
    //Get the EDT information from field of a table. Here Field AccountNum from table CustTable
    //has been taken for example.
    dialog.addField(new sysDictType(new dictionary().typeName2Id(edtName)).extendedTypeId());
    return dialog;
}


1 comment: