How to add lookup form on Runbase Dialog

Hi All,

Today, I am demonstrating on how to add lookup form on RunBase Dialog.
Firstly, I want to give a brief introduction about RunBase Class.
This Class is used to schedule the batch jobs. So, Adding lookup form
to RunBase Dialog starts with Class Declaration.

class SampleComboDialog extends RunBaseBatch
{

DialogRunbase dialog;
DialogField nameField;

}

In the above class declaration, I declared dialog object of type DialogRunbase & nameField of type DialogField and then i overrided dialog method.

protected Object dialog()
{

FormStringControl   control;
dialog = super();
namefield = dialog.addField(extendedTypeStr(Name));
control = namefield.control();
control.registerOverrideMethod(methodStr(FormStringControl,lookup),

methodStr(SampleComboDialog,nameLookup),this);
return dialog;

}

You have to override the lookup() method with lookup form being as parameter.

rivate void nameLookup(FormStringControl _control)
{
SysTableLookup sysTableLookup;
QueryBuildDataSource qbds;

Query query = new Query();
qbds = Query.addDataSource(tableNum(SampleAIFTbl));
sysTableLookup = SysTableLookup::newParameters(tableNum(SampleAIFTbl), _control,true);
sysTableLookup.addLookupfield(fieldNum(SampleAIFTbl, Name), true);
sysTableLookup.parmQuery(query);
sysTableLookup.performFormLookup();

}

Binding this nameField with FormStringControl, used registerOverrideMethod to be used as overridden method by dialog object.

Simple run method

public void run()
{
super();
info(strFmt(” the result is %1″, nameField.value()));
}

It displays the value selected in lookup but it requires to initialization of RunBase Class Object. This is has to be written in main method of respective class.

public static void main(Args _args)
{
SampleComboDialog sampleComboDialog;
sampleComboDialog = new SampleComboDialog();

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

So, I compile & run it and here is the Output.

Lookup1

Suppose, If I select Add Operation from the lookup and press ok then, here it is the output.

lookup2

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: