Sunday, April 12, 2020

Basic Dialog Form in Ax 2012

class TTC_AY extends RunBase
{
    DialogField fieldName,fieldId;
    TTC_CustomerTable   custTable;
    TTC_CustomerTable2  custTable2;
    TTC_CustID custId;
    TTC_Name custName;
}




protected Object Dialog()
{
    Dialog dialog;
    ;
    dialog = super();
    dialog.caption('Atul Dialog');
    fieldId   =  dialog.addField(extendedTypeStr(TTC_CustID), 'Customer Id');
    fieldName     =  dialog.addField(extendedTypeStr(TTC_Name),'Customer Name');
    return dialog;
}




public boolean getFromDialog()
{
    custId     = fieldId.value();
    custName   = fieldName.value();
    return super();
}




public void run()
{
    while select * from custTable
        where custTable.Name == custName
            && custTable.Id == custId

    if (custTable)
    {
        info( strFmt('%1 -- %2',custTable.Id, custTable.Name));
        custTable2.Id           = custTable.Id;
        custTable2.Name         = custTable.Name;
        custTable2.Email        = custTable.Email;
        custTable2.Phone        = custTable.Phone;
        custTable2.Gender       = custTable.Gender;
        custTable2.CustomerType = custTable.CustomerType;
        custTable2.Balance      = custTable.Balance;
        custTable2.Age          = custTable.Age;
        custTable2.Address      = custTable.Address;
        custtable2.insert();
    }
    else
    {
        error( 'Customer not found!');
    }
}




public static void main(Args _args)
{
    TTC_AY custCreate = new TTC_AY();
    if (custCreate.prompt())
    {
        custCreate.run();
    }
}