title: Create a lookup filter for a dialox in Dynamics AX 4.0
body: <p>I'm trying to create a custom lookup filter in a dialog in AX. </p>
  
  <p>I've followed the instructions in this post <a href="https://stackoverflow.com/questions/5632147/filter-look-up-in-dialog">x++ filter lookup in dialog</a> and am getting a Stack Trace error -- FormRun object not initialized -- when I'm run my code. </p>
  
  <p>What I am trying to do is filter the lookup() for the ConfigId EDT based on the selection from the ItemId EDT. I have the custom lookup() ready to go and working properly, I just can't get it called from my dialog box.</p>
  
  <pre><code>public Object dialog(DialogRunbase _dialog, boolean _forceOnClient)
  {
      DialogRunBase   dialog;
      ;
  
      dialog = super(_dialog, true);
  
      dialog.caption('@RID2885');
  
      dfItem = dialog.addField(typeid(ItemId));
      dfInventLoc = dialog.addField(typeid(InventLocationId));
      dfReplaceCost = dialog.addField(typeid(PdsCost));
      dfItemConfig = dialog.addField(typeid(ConfigId));
      dfColorId = dialog.addField(typeid(InventColorId), '@RID101');
  
      return dialog;
  }
  </code></pre>
  
  <p>Here's the call to the lookup():</p>
  
  <pre><code>void Fld_7_lookup()
  {
      Formrun fr = this.dialogModify().parmDialog();
      Object control = fr.controlCallingMethod();    
      ;
  
      ConfigTable::lookupConfigIdSimple(control, dfItem.value());    
  }
  </code></pre>
  
  <p>And this is where it keeps getting the Stack Trace error:</p>
  
  <pre><code>public void dialogPostRun(DialogRunbase _dialog)
  {
      ;
       super(_dialog);
      **_dialog.formRun().controlMethodOverload(true);** // Causes Stack Trace error
      _dialog.formRun().controlMethodOverloadObject(this);       
  }
  </code></pre>
  
  <p>I have tried multiple configurations with the dialog box. When the code reaches that point, it still has information passed in from the dialog() method, but when it goes to get the FormRun, that object is blank.</p>
  
  <p>Could someone please help me understand why there is no FormRun object associated with the DiaglogRunBase that is passed-in?</p>
  
  <p>Thanks.</p>