web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

adding custom lookup - without setting the value on the control.

(0) ShareShare
ReportReport
Posted on by

Hello,

I added a code like this (on lookup event on control):

    DictEnum dictENum;
    SysTableLookup lookupTable;
    int i;
    FormStringControl c;
    Query q;
    TmpSysTableField tmpSysTableField;
    SysDictType sysDictType;
    DictRelation dictRelation;
    DictField    relatedField;

    SysFieldGroupLookup     sysFieldGroupLookup;
    FormRun formRun;
    Args    args;
    str saveTxt;

    c = element.control(parameterValue.id());
    saveTxt = c.text();

            dictENum = new dictENum(enumName2Id('NoYesCombo'));
            lookupTable = SysTableLookup::newParameters(tableNum(TmpSysTableField), c);
            lookupTable.setLabel("@SYS131692");
            lookupTable.addLookupfield(fieldNum(TmpSysTableField, FieldLabel));

            if (dictENum)
            {
                for (i = 0; i < dictENum.values(); i++)
                {
                    tmpSysTableField.FieldLabel = dictENum.value2Label(i);
                    tmpSysTableField.insert();
                }
            }
            lookupTable.parmTmpBuffer(tmpSysTableField);
            lookupTable.performFormLookup();

c.text(saveText + 'bbbb');
}


I want that the control will get the value after the lookup.

1. Even SysTableLookup::newParameters( ... , false) - I thought that the control won't get the value to the control - Anyway the control is getting the value (I need to do same as SysQueryForm does (appending the value, when using range values).

2. Nevertheless, the line: c.text(saveText + 'bbbb'); doesn't change any text on control (text is the same as it was before lookup method, even I remark and didn't call super() on this function.

Thanks :)

*This post is locked for comments

I have the same question (0)
  • Douglas Noel Profile Picture
    3,905 on at

    Hi,

    1) you should keep in mind that the call of performFormLookup is an asynchronous one. Like Windows message oriented programming it will return immediately not at the moment the lookup is closed.

    2) your call c.text(xxx) will update the control in all cases, if you try a c.updateWindow() right after. Here the UpdateWindow method is calles directly. But remember the lookup is open.here.

    There is no event to my knowledge like OnEndOfLookup or something which is triggered when you close the lookup form sometime where you can put the code.

    But you can use the following workaround:

    After selecting a value in the lookup form, the controls validate() method is called.

    Maybe you're going to flag this using a forms variable boolean inLookup or something else.

    you can set this variable to true right before the performFormLookupCall().

    within validate() of the contol you can do somthing like

    if (inLookup)

    {

      in lookup = false;

      this.text() = this.text()+'bbb';

    }

    and mayve resetting this variable to false on other events like leaverecord, executequery, ....

    The other way could be waiting for the close of the lookup form but you should create a own lookup formrun and do a wait() on then form

    regards

    Douglas

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Joris dG Profile Picture

Joris dG 5

#2
Alexey Lekanov Profile Picture

Alexey Lekanov 2

#2
Henrik Nordlöf Profile Picture

Henrik Nordlöf 2 User Group Leader

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans