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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested Answer

How to open a dialog box with a lookup field from a form control event handler .

(0) ShareShare
ReportReport
Posted on by 113

Hi ,
Can anyone help me on this.

How to open a dialog box with a lookup field from a form control event handler .

I have the same question (0)
  • HARISH MEHRA Profile Picture
    113 on at

    public class ReasonCodeDialog_Cap

    {

    [FormControlEventHandler(formControlStr(SalesTable, SalesLine_SalesPrice), FormControlEventType::Modified)]

           public static void SalesLine_SalesPrice_OnModified(FormControl sender, FormControlEventArgs e)

           {

               FormDataSource salesLine_ds = sender.formRun().dataSource("SalesLine");

               SalesLine      salesLine      = salesLine_ds.cursor();

               Dialog dlg = new Dialog();

               ReasonMain_CAP reason_Cap;

               PriceChangeHistory_Cap priceChangeHistory;

               DialogField dfReasonCode = dlg.addField(extendedTypeStr(ReasonCode_CAP),'ReasonCode');

               Query query = new Query();

               QueryBuildDataSource queryBuildDataSource;

               QueryBuildRange queryBuildRange;

               SysTableLookup sysTableLookup =

               SysTableLookup::newParameters(tableNum(ReasonMain_CAP), sender);

               sysTableLookup.addLookupField( fieldNum(ReasonMain_CAP,ReasonCode ));

               queryBuildDataSource = query.addDataSource(tableNum(ReasonMain_CAP));

               sysTableLookup.parmQuery(query);

               sysTableLookup.performFormLookup();

               FormBuildStringControl control;

               control = dfReasonCode.control();

               control.registerOverrideMethod('LookUp','performFormLookup',dfReasonCode);

               if (dlg.run())

               {

                   if (dfReasonCode.value() != '' )

               dlg.closedOk();

    Getting Error on registerOverrideMethod.

  • Suggested answer
    Mohit Rampal Profile Picture
    12,565 Moderator on at

    Hi Harish, Are you asking on how to override lookup method using form event handlers?

    If yes, then check this out

    stoneridgesoftware.com/.../

    dynamics365musings.com/.../

  • HARISH MEHRA Profile Picture
    113 on at

    No Actually when the  on Modified event run ,a dialog will pop up with a drop down .

  • Suggested answer
    Mohit Rampal Profile Picture
    12,565 Moderator on at

    Your another post is more clear, Please delete the duplicate post.

    As per your code, I think you need to display Dialog with Reason Code on why Sales price was modified. Have you debugged the code and on which line its throwing error and what's the error?

  • HARISH MEHRA Profile Picture
    113 on at

    Thanks Mohit for the reply.

    Yes you are right need to display Dialog with Reason Code on why Sales price was modified.

    Throwing error on Getting Error on registerOverrideMethod.

    In the Line - control.registerOverrideMethod('LookUp','performFormLookup',dfReasonCode);

  • Martin Dráb Profile Picture
    237,965 Most Valuable Professional on at

    Please never tell us just something like "it's throwing an error". Tell us what error you're getting. We can't help you if don't give us basic information.

    Also, how is performFormLookup() defined?

  • Suggested answer
    Mohit Rampal Profile Picture
    12,565 Moderator on at

    Can you try commenting below 3 lines from your code

    FormBuildStringControl control;

    control = dfReasonCode.control();

    control.registerOverrideMethod('LookUp','performFormLookup',dfReasonCode);

    I tried to use your code on standard fields and got below error when clicked on Reason code lookup in Dialog

    pastedimage1678345187560v1.png

    And commenting that 3 lines seems to be working

    pastedimage1678345194297v2.png

  • Martin Dráb Profile Picture
    237,965 Most Valuable Professional on at

    Yes, Harish already told us that the error is thrown by registerOverrideMethod() method. If we doesn't call it, he won't get the error, but he would also lose functionality.

  • HARISH MEHRA Profile Picture
    113 on at

    I tried commenting the 3 lines as mentioned  by you above but the lookup for reason code is not visible for me in the Dialog .

  • Mohit Rampal Profile Picture
    12,565 Moderator on at

    I didn't understood why registerOverride method is required in your code. Do you want to override Reason Code lookup that will be displayed in the dialog?

    Regarding, lookup not visible after commenting code, as per your code EDT for Reason code is ReasonCode_CAP. I tried standard ReasonCode EDT which has Table relation to ReasonTable. In your case, what is the source table for ReasonCode?

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 551 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 450 Super User 2025 Season 2

#3
BillurSamdancioglu Profile Picture

BillurSamdancioglu 278 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans