0

MS Dynamics AX 4.0

I have a class with a dialog that extends RunBase, a dialogField of Range type and a custom lookup for it. It works as planned but one thing upsets me. Normal lookup opens on Alt + Down key combination, but it doesn't work in my dialog. I assume this is because "Range" EDT is not related to any TableField. But I have my own lookup, can I force it somehow to drop down on Alt + Down?

Here is my dialog method:

protected Object dialog(DialogRunBase dialog, boolean forceOnClient)
{
    Object                      ret;
    ;
    ret = super(dialog, forceOnClient);
    dialogFld = new DialogField(ret, typeid(Range), 100);
    dialogFld.init(ret);
    dialogFld.lookupButton(FormLookupButton::Always);
    dialogFld.fieldControl().replaceOnLookup(false);

    return ret;
}

Here is my lookup, as you can see, it's based on ItemId EDT:

protected void Fld100_1_Lookup()
{
    TableLookup_RU          sysTableLookup = new TableLookup_RU();
    Query                   query          = new Query();
    FormRun                 lookupForm;
    QueryBuildDataSource    qbds           = query.addDataSource(tablenum(InventTable));
    ;
    sysTableLookup.parmTableId(tablenum(InventTable));
    sysTableLookup.parmCallingControl(dialogFld.fieldControl());

    sysTableLookup.addLookupfield(fieldnum(InventTable, ItemId));
    sysTableLookup.addLookupfield(fieldnum(InventTable, ItemName));

    findOrCreateRange_W(qbds, fieldnum(InventTable, ItemType), SysQuery::valueNot(ItemType::Service));

    sysTableLookup.parmQuery(query);
    lookupForm = sysTableLookup.formRun();
    dialogFld.fieldControl().performFormLookup(lookupForm);
}

And dialogPostRun:

public void dialogPostRun(DialogRunbase dialog)
{
    ;
    dialog.formRun().controlMethodOverload(true);
    dialog.formRun().controlMethodOverloadObject(this);
    super(dialog);
}

This problem is not that critical, but it bothers me. If someone could help, I'd be really grateful.

P.S.: I could use ItemId typeId, but I need to append many items, and ItemId is only 20 chars long..

Cathome
  • 11
  • 1
  • 5

2 Answers2

1

I've discovered that I don't have to use Range typeid for the dialogField. dialogField.limitText(int) works just fine, it overrides the length of EDT. So I changed dialog method like this:

protected Object dialog(DialogRunBase dialog, boolean forceOnClient)
   {
       Object                      ret;
       ;
       ret = super(dialog, forceOnClient);
       dialogFld = new DialogField(ret, typeid(ItemId), 100); //if typeId doesn't have relations Alt + Down doesn't work
       dialogFld.init(ret);
       dialogFld.label("@SYS72708");
       dialogFld.lookupButton(FormLookupButton::Always);
       dialogFld.limitText(200);
       dialogFld.fieldControl().replaceOnLookup(false);

       return ret;
   }
Cathome
  • 11
  • 1
  • 5
0

Create a new extended data type ItemIdRange, extend from Range. Be sure to set the relation on the new type to relate to InventTable.ItemId to get automatic lookup.

Also the form control must have property ReplaceOnLookup set to no, to allow the user to add more criteria. For a DialogRunbase field this may be done this way:

FormStringControl fsc = dialogField.control();
fsc.replaceOnLookup(false);

The code posted in the question is then not needed.

Jan B. Kjeldsen
  • 17,817
  • 5
  • 32
  • 50
  • Hi, thanks, this is certainly working solution, but I wish to make minimum customizations and would like to avoid creating new EDT. Sorry I haven't mentioned my AX version, it's 4.0. I Assume that registerOverrideMethod would do the work, as described here https://stackoverflow.com/a/40725646/4925022, but it's implemented only since 2012, so I can't check. – Cathome Mar 07 '18 at 09:45