Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Performing run time lookup for a Custom EDT

(0) ShareShare
ReportReport
Posted on by

Hi All,

I have created a new EDT(MyEcoResCategoryHierarchyId) and attached it to a field in a table MY_EcoResCategoryHierarchy(this table is created by me).I want to perform run time lookup in a dialog on the field which is using my new EDT MyEcoResCategoryHierarchyId .I have written the below code to perform this functionality:

class LookupDialog extends RunBase
{
DialogRunbase dialog;
DialogField dialogField;

}

public Object dialog()
{
dialog = super();

dialogField = dialog.addFieldValue(extendedTypeStr(MyEcoResCategoryHierarchyId),"Category Hierarchy");
return dialog;

}

public void dialogPostRun(DialogRunbase _dialogloc)
{

super(_dialogloc);

_dialogloc.dialogForm();
_dialogloc.dialogForm().formRun().controlMethodOverload(true);
_dialogloc.dialogForm().formRun().controlMethodOverloadObject(this);
_dialogloc.formRun().controlMethodOverload(true);
_dialogloc.formRun().controlMethodOverloadObject(this);

}

public void Fld1_1_lookup()
{
Query query = new Query();
QueryBuildDataSource qbds;
SysReferenceTableLookup sysTableLookup;

FormControl frmStr = dialogField.dialog().formRun().controlCallingMethod();
sysTableLookup = SysReferenceTableLookup::newParameters(tableNum(MY_EcoResCategoryHierarchy),frmStr);
sysTableLookup.addLookupfield(fieldNum(MY_EcoResCategoryHierarchy, Code));

query = new query();
qbds = query.addDataSource(tableNum(MY_EcoResCategoryHierarchy));
qbds.fields().addField(fieldNum(MY_EcoResCategoryHierarchy,Code));

sysTableLookup.parmQuery(query);
sysTableLookup.performFormLookup();

}

static void main(Args _args)
{
LookupDialog lookupDialog = new LookupDialog();

if (lookupDialog.prompt())
{
lookupDialog.run();
}
}

If I run the above code, control is not added to the dialog,hence unable to perform lookup on the same.The dialog is opened empty.

Note: The same code is working fine if I am using a standard EDT(For example: EcoResCategoryHierarchyId in place of my new EDT).

Please help me in resolving this issue.

Regards,

Padmaja

*This post is locked for comments

  • Suggested answer
    LiuJie Xu Profile Picture
    90 on at
    RE: Performing run time lookup for a Custom EDT

    If you are using D365FO, I found that you need to set the "Replacement key" in table property. This will help you to add the relevent fields under the "AutoIdentification" field group. After that, it will appear in the dialog you made.

  • Suggested answer
    Nishant2408 Profile Picture
    705 on at
    RE: Performing run time lookup for a Custom EDT

    Hi Padmaja,

    Code looks fine here but why is it not working that you can debug and check.

    You can use the below code to fulfil your requirement as well.

    class LookupDialog extends RunBase

    {

       DialogRunbase dialog;

       DialogField dialogField;

    }

    public Object dialog()

    {

       FormStringControl           control;

       dialog = super();

       dialogField = dialog.addFieldValue(extendedTypeStr

                                              (MyEcoResCategoryHierarchyId),"Category Hierarchy");

       control = dialogField.control();

       control.registerOverrideMethod(methodStr(FormStringControl, lookup),

                                      methodStr(LookupDialog, Fld1_1_lookup),

                                      this);

       return dialog;

    }

    public void Fld1_1_lookup(FormStringControl _control)

    {

       Query query = new Query();

       QueryBuildDataSource qbds;

       SysTableLookup sysTableLookup;

       sysTableLookup = SysTableLookup::newParameters(tableNum

                                                                       (MY_EcoResCategoryHierarchy),_control);

       sysTableLookup.addLookupfield(fieldNum(MY_EcoResCategoryHierarchy, Code));

       qbds = query.addDataSource(tableNum(MY_EcoResCategoryHierarchy));

       sysTableLookup.parmQuery(query);

       sysTableLookup.performFormLookup();

    }

    static void main(Args _args)

    {

       LookupDialog lookupDialog = new LookupDialog();

       if (lookupDialog.prompt())

       {

           lookupDialog.run();

       }

    }

  • Community Member Profile Picture
    on at
    RE: Performing run time lookup for a Custom EDT

    Hi,

    I synchronized the data dictionary completely,cleared caches after adding the EDT.Still no luck:(

    regards,

    Padmaja

  • Suggested answer
    Vilmos Kintera Profile Picture
    46,149 on at
    RE: Performing run time lookup for a Custom EDT

    Make sure your Data Dictionary is fully synchronized after the EDT has been added.

    Also you might want to use addSelectionField as well, see the example below:

    parthav-dynamicsax.blogspot.hu/.../adding-lookup-method-on-form-reference.html

  • Mea_ Profile Picture
    60,278 on at
    RE: Performing run time lookup for a Custom EDT

    Hi Padmaja_AX,

    Your code looks ok. If you are saying that it works with different EDT you can try to refresh caches from Tools -> Caches .

    If this won't help you can always debug and see what exactly is wrong.

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

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Kudos to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Microsoft Dynamics AX (Archived)

#1
Mohamed Amine Mahmoudi Profile Picture

Mohamed Amine Mahmoudi 100 Super User 2025 Season 1

#2
Community Member Profile Picture

Community Member 48

#3
shanawaz davood basha Profile Picture

shanawaz davood basha 6

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans