Sunday, June 23, 2019

Create dialog run time and update respective record on Dialog

Below are the method to create Dialog dynamically, inter value, fetch value from dialog and update dialog field automatically :

class DialogDemo extends RunBase
{
    DialogField     fieldAccount;
    DialogField     fieldName; 
    DialogField     fieldGroup;
    VendAccount     vendAccount;
    VendName        vendName;
    VendGroupId     vendGroupId;
 
 }

//Convert object to container
    Public Container pack()
    { 
        return conNull();
    }

//Convert container to object
  Public boolean unpack(container _packedClass)
    {
        return true;
    }

// Dialog layout
Object dialog()
{
Dialog          dialog;
dialog = super();
dialog.caption("Customer information");
dialog.allowUpdateOnSelectCtrl(true);
fieldAccount=dialog.addField(Extendedtypestr(VendAccount),"Vendor Account");
fieldName=dialog.addField(Extendedtypestr(VendName));
fieldName.enabled(false);
dialog.addTabPage("Details");
fieldgroup=dialog.addField(Extendedtypestr(vendGroupId));
fieldgroup.enabled(false);
return dialog;

}

//Fetch value from Dialog
public boolean getFromDialog()
{
    vendAccount=fieldAccount.value(); 
    vendName=fieldName.value();
    vendGroupId=fieldGroup.value();
    return super();
}

public static void main(Args _args)
{
    DialogDemo dialogDemo= new DialogDemo();
    if(DialogDemo.prompt())
    {
    DialogDemo.run();
    }
}
//field value assignment
public void dialogSelectCtrl()
{
VendTable   vendTable;
vendTable=vendTable::find(fieldAccount.value());
fieldName.value(vendTable.name());
fieldGroup.value(vendTable.VendGroup);

}

//To execute logic
Public void run()
{
    info(strFmt("Vend Account: %1", vendAccount));
    info(strFmt("Vend Name: %1", vendName));
    info(strFmt("Vend Group: %1", vendGroupId));
}

No comments:

Post a Comment