1. Open the AOT, and create a new class with the following code, its important ro extend RunBase because the RunBase framework uses the Dialog framework to prompt a user for data input. It uses the SysLastValue framework to persist usage data and the Operation Progress framework to show operation progress:
1
2
3
4
5
6
7
8
| class CustCreateDialog extends RunBase { DialogField fieldAccount; DialogFIeld fieldName; CustTable custTable; CustAccount custAccount; } |
2. Override the method Dialog, this method will be used to give “form” to our Dialog:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
| protected Object Dialog() { Dialog dialog; ; dialog = super(); // Set a title for dialog dialog.caption( 'Simple Dialog' ); // Add a new field to Dialog fieldAccount = dialog.addField( extendedTypeStr(CustVendAC), 'Customer account' ); return dialog; } |
3. Override the method getFromDialog, the code below will be used to retrieve the Dialog field values:
1
2
3
4
5
6
7
| public boolean getFromDialog() { // Retrieve values from Dialog custAccount = fieldAccount.value(); return super(); } |
4. Override the method run, use it to process whatever you want to. On my example I will use it to show the customer account information on infolog.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
| public void run() { // Set Dialog field value to find CustTable custTable = CustTable::find(custAccount); if (custTable) { // Shows retrieved information info( strFmt( '%1 -- %2' , custTable.AccountNum, custTable.name())); } else { error( 'Customer Account not found!' ); } } |
5. Create a new main method to execute your class.
1
2
3
4
5
6
7
8
9
10
| 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(); } } |
6. Execute your class, check results.
OTHER WAY
Dialog dialog = new Dialog("@SYS23133");
DialogField dialogAccountId=
dialog.addField(extendedTypeStr(BankAccount));
DialogField dialogFromChequeNum =
dialog.addField(extendedTypeStr(BankChequeStartNum),"@SYS4083");
DialogField dialogNumOfCheque =
dialog.addField(extendedTypeStr(BankChequeQty),"@SYS14578");
dialogAccountId.Value("456");
dialogAccountId.Active(false);
dialogFromChequeNum.Value(FromChequeNum);
dialogNumOfCheque.Value(NumOfCheque);
if (dialog.run())
{
FromChequeNum = dialogFromChequeNum.Value();
NumOfCheque = dialogNumOfCheque.Value();
return true;
}
return false;
No comments:
Post a Comment