Tuesday, April 9, 2019

How to create a Dialog form by extending Runbase class

class CustCreateDialog extends RunBase
{
    DialogField fieldAccount;
    DialogFIeld fieldGroup;

    CustTable   custTable;
    CustTrans   custTrans;
    CustAccount custAccount;
    CustGroupId custGroup;
}

--------------------------------------------------------------------------------------------------------------------------

protected Object Dialog()
{
    Dialog dialog;
    ;

    dialog = super();

    // Set a title for dialog
    dialog.caption( 'Simple Dialog');

    // Add a new field to Dialog
    fieldGroup   =  dialog.addField(extendedTypeStr(CustGroupId), 'Customer Group');
    fieldAccount = dialog.addField(extendedTypeStr(CustAccount),'Customer account');

    return dialog;
}

-------------------------------------------------------------------------------------------------------------------------

public boolean getFromDialog()
{
    // Retrieve values from Dialog
    custAccount = fieldAccount.value();
    custGroup   = fieldGroup.value();
    return super();
}


-------------------------------------------------------------------------------------------------------------------------

public void run()
{
    while select AccountNum, CustGroup from custTable
        where custTable.AccountNum == custAccount
            && custTable.CustGroup == custGroup
        join Voucher, AmountCur, TransDate from custTrans
            where custTrans.AccountNum == custTable.AccountNum
       
    if (custTable)
    {
        // Shows retrieved information
        info( strFmt('%1 -- %2 -- %3 --- %4 ---%5' , custTable.AccountNum, custTable.name(), custTrans.Voucher, custTrans.AmountCur, custTrans.TransDate));
    }
    else
    {
        error( 'Customer Account not found!');
    }
}

--------------------------------------------------------------------------------------------------------------------------

public static void main(Args _args)
{
    CustCreateDialog custCreate = new CustCreateDialog();

    // Prompt the dialog, if user clicks in OK it returns true
    if (custCreate.prompt())
    {
        custCreate.run();
    }
}

2 comments:

  1. Thanks for sharing this.,
    Leanpitch provides online training in Scrum Master during this lockdown period everyone can use it wisely.
    Join Leanpitch 2 Days CSM Certification Workshop in different cities.

    CSM training online

    ReplyDelete
  2. you have provide code ,i am new please share step by step processes of dialog from

    ReplyDelete

How to enable the dimension fields based on the Item selected on the form.

[Form] public class KMTShipFromWarehouses extends FormRun {     InventDimCtrl_Frm_EditDimensions        inventDimFormSetup;     /// &l...