Axaptapedia is now maintained by AgileCadence For more information please click here.

Override Lookup on DialogField

From Axaptapedia
Jump to: navigation, search

At some point I had to filter a dialogfield, based on some other values on the dialog. But you can't override a lookup on a dialogfield, With this pattern you can achieve the same.

Create a special extended datatype for use on the dialog and create a lookup form for this EDT and specify it on the FormHelp property.

On the DialogClass, create parmMethods to expose the values you need.

So far nothing special, but now the trick:

On the Lookup form, override the init method:

<xpp> public void init() {

   SysSetupFormRun sysSetupFormRun;
   DialogRunBase dialogRunBase;
   
   MyDialogClass myDialogClass;
   str   filterValue;
   ;
   super();
   // the field to use in the lookup
   element.selectMode(Grid_PrimaryID);
   try
   {
       //getting a reference to the dialog is the trick:
       SysSetupFormRun = element.args().caller();
       dialogRunBase = SysSetupFormRun.args().caller();
       myDialogClass = dialogRunBase.caller();

       // use the parm methods to retrieve the values
       filterValue = myDialogClass.parmValue();
       
       // pass the value to a querbuildrange
       // that has been initialized in the init method
       // of the datasource
       qbrFilter.value(filterValue);

   }
   catch
   {
       error("Couldn't retrieve caller information.");
   }

} </xpp>