Skip to main content

Notifications

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 100

Hi ,
Can anyone help me on this.

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

  • Mohit Rampal Profile Picture
    12,558 Moderator on at
    RE: How to open a dialog box with a lookup field from a form control event handler .

    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?

  • HARISH MEHRA Profile Picture
    100 on at
    RE: How to open a dialog box with a lookup field from a form control event handler .

    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 .

  • Martin Dráb Profile Picture
    232,866 Most Valuable Professional on at
    RE: How to open a dialog box with a lookup field from a form control event handler .

    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.

  • Suggested answer
    Mohit Rampal Profile Picture
    12,558 Moderator on at
    RE: How to open a dialog box with a lookup field from a form control event handler .

    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
    232,866 Most Valuable Professional on at
    RE: How to open a dialog box with a lookup field from a form control event handler .

    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?

  • HARISH MEHRA Profile Picture
    100 on at
    RE: How to open a dialog box with a lookup field from a form control event handler .

    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);

  • Suggested answer
    Mohit Rampal Profile Picture
    12,558 Moderator on at
    RE: How to open a dialog box with a lookup field from a form control event handler .

    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
    100 on at
    RE: How to open a dialog box with a lookup field from a form control event handler .

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

  • Suggested answer
    Mohit Rampal Profile Picture
    12,558 Moderator on at
    RE: How to open a dialog box with a lookup field from a form control event handler .

    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
    100 on at
    RE: How to open a dialog box with a lookup field from a form control event handler .

    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.

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 🌸

WIN Power Platform Community Conference 2025 tickets!

Jonas ”Jones” Melgaard – Community Spotlight

We are honored to recognize Jonas "Jones" Melgaard as our April 2025…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 294,095 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 232,866 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,158 Moderator

Leaderboard

Product updates

Dynamics 365 release plans