Search This Blog

Sunday, 27 July 2014

Dialog Events(Modified, lookups ) in AX 2009

Hi ,

Today i would like to share you how to do look-up filtration , modified method in dialog using dialog class

lookup :

void Fld5_1_lookup()
{
     Formrun                 fr = dialog.formRun();
    object                  Control = fr.controlCallingMethod();

    SysTableLookup          sysTableLookup =
    SysTableLookup::newParameters(tablenum(CEKMasterCostCardTable),  fieldMccId.fieldControl());
    Query                   query = new Query();
    QueryBuildDataSource    queryBuildDataSource;
    QueryBuildRange         queryBuildRange;
    ;


    sysTableLookup.addLookupfield(fieldnum(CEKMasterCostCardTable, AccountNum),false);
    sysTableLookup.addLookupfield(fieldnum(CEKMasterCostCardTable, Name),false);
    sysTableLookup.addLookupfield(fieldnum(CEKMasterCostCardTable, Type),true);
    sysTableLookup.addLookupfield(fieldnum(CEKMasterCostCardTable, Active),false);
    sysTableLookup.addLookupfield(fieldnum(CEKMasterCostCardTable, MccId),false);


    queryBuildDataSource = query.addDataSource(tablenum(CEKMasterCostCardTable));
    queryBuildRange =         queryBuildDataSource.addRange(fieldnum(CEKMasterCostCardTable,AccountNum));
    queryBuildRange.value(queryvalue(fieldCustAccount.value()));


    sysTableLookup.parmQuery(query);
    sysTableLookup.parmUseLookupValue(false);
    sysTableLookup.performFormLookup();
}

modified :

public boolean Fld2_1_modified()

{
    FormCheckBoxControl control = dialog.formRun().controlCallingMethod();

    boolean isFieldModified;
    ;

    isFieldModified = control.modified();


    if(isFieldModified)
    {
        filedChkNewCard.value(0);
        fieldCustAccount.allowEdit(false);
        fieldMccId.allowEdit(false);
   
    }

    return isFieldModified;

}

dialog:

protected Object dialog()
{

    ;
    dialog = super();

    dialog.caption("Select  One of three below options or cancel");

    dialog.allowUpdateOnSelectCtrl(true);

   fieldChkBlankCard=dialog.addField(Typeid(NoYes),"Create New Blank Cost Card");
   fieldChkSelectedCard=dialog.addField(Typeid(NoYes),"Copy from selected "+cEKMasterCostCardTable.Name+','+cEKMasterCostCardTable.Type+','+cEKMasterCostCardTable.MccId);
   filedChkNewCard=dialog.addField(Typeid(NoYes),"Copy from Other Customer");

    fieldCustAccount    = dialog.addField(typeid(CustAccount)," Customer ID");
    fieldMccId = dialog.addField(typeid(CEKMccId),"MCC ID");
    fieldType=dialog.addField(typeid(str200),"Type");

    fieldText=dialog.addField(typeid(Notes));

    okButton = dialog.formBuildDesign().control('OKButton');

    okButton.enabled(false);

    return dialog;
}

dialogPostRun:

public void dialogPostRun(DialogRunbase  _dialog)
{
    super(_dialog);
    _dialog.dialogForm().formRun().controlMethodOverload(true);
    _dialog.dialogForm().formRun().controlMethodOverloadObject(this);
}

pack:

public container pack()
{
    return connull();
}

unpack:

public boolean unpack(container packedClass)
{
    return true;
}

class delcaration:

class CEKMasterCostCardDialog extends RunBase
{
    DialogField fieldCustAccount;
    DialogField fieldMccId,fieldText,fieldType;
    DialogField fieldChkBlankCard,fieldChkSelectedCard,filedChkNewCard;
    FormBuildCommandButtonControl   okButton;
    CEKMasterCostCardTable cEKMasterCostCardTable;
    str Mcc;

    Dialog          dialog;

}
main:

public static void main(Args args)
{

    CEKMasterCostCardDialog cekMasterCostCardDialog;
    CEKMasterCostCardTable cekMasterCostCardTable;
    ;

    cekMasterCostCardDialog = new   CEKMasterCostCardDialog();

    if(cekMasterCostCardDialog.prompt())
    {
    cekMasterCostCardDialog.run();
    }

}

click here for the syntax in Dialog class.

click here  for detail explanation.


Happy daxing.....


No comments:

Post a Comment