I read in some other blog how to apply customer methods such as lookup() to a standard dialog. The trick is to apply a Field Identifier to the dialog field, and then create a method that follows the naming convention so it will be found at runtime. See the example below:
A)
|
class myClass extends RunBase { Dialog dialog; #define.FID_OPPORTUNITYID(903) }
// Add fields to the dialog protected Object dialog(DialogRunbase _dialog, boolean _forceOnClient) { DialogRunbase dialog = super(); DialogGroup dialogGroup; ; dialogGroup = dialog.addGroup("@SYS102068"); dlgFldOpportunityId = new DialogField(dialog, typeid(smmOpportunityId), #FID_OPPORTUNITYID); dialog.addCtrlDialogField(dlgFldOpportunityId.name()); dlgFldOpportunityId.init(dialog); dlgFldOpportunityId.value(opportunityId); return dialog; }
//prefiltered lookup for opportunityId private void fld903_1_lookup() { FormStringControl control = dialog.formRun().controlCallingMethod(); SysTableLookup sysTableLookup = SysTableLookup::newParameters(tablenum(smmOpportunityTable), control); Query query = new Query() ; QueryBuildDataSource qbds; ; sysTableLookup.addLookupfield(fieldnum(smmOpportunityTable, OpportunityId)); sysTableLookup.addLookupfield(fieldnum(smmOpportunityTable, Subject)); qbds = query.addDataSource(tablenum(smmOpportunityTable)); if(partyId) SysQuery::findOrCreateRange(qbds,fieldnum(smmOpportunityTable, PartyId)).value(partyId); sysTableLookup.parmQuery(query); sysTableLookup.performFormLookup(); }
|
This is very neat if you need to enhance only one special field, however I quickly noticed, that when you start improving the user interface, you will add the next function and the next and so on. Then the trick above is not the way to go. It is much easier to add a customer dialog as follows:
B)
class myClass extends RunBase { Dialog dialog; }
protected Object dialog(DialogRunbase _dialog, boolean _forceOnClient) { DialogGroup dialogGroup; ; //dialog = super(); dialog = Dialog::newFormnameRunbase(formstr(CustomDialog),this); dialog.caption(Runbase::getDescription(classidget(this))); dialogGroup = dialog.addGroup("@SYS102068"); //add custom fields, without special functionality return dialog; }
|
The corresponding form needs to have the following groups and buttons to work. In addition to those groups you can add various other fields, datasources etc. with all the handlers – such as lookup() – you like. You can pass the results by extracting myClass with element.args().caller().runbase() and implementing some parm methods on myClass, which you can access in edit methods.
|

|
//edit methods can be drag and dropped into the design section edit ItemId itemId(boolean _set, ItemId _itemId) { ItemId ret; ; if(_set) { myClass.parmItemId(_itemId); } ret = myClass.parmItemId(); return ret; }
|
Thomas
Leave a Reply