/ Microsoft / How to create lookup in form data source field in D365FO

How to create lookup in form data source field in D365FO

Learn, share and spread knowledge

Creating lookup on form is very common requirement for a better user experience. In this blog post, I will discuss about how to create lookup in form data source field using in D365FO. I will create this using extension approach in Microsoft Dynamics 365 for Finance and Operations.

Previously, I have created a post in which I have discussed about how to create lookup in D365FO using x++ in which the event handler method of OnLookup event of FormControlString is implemented. But, one of our senior community member mentioned that creating lookup in form data source field is a better approach than handling it on the FormStringControl.

According to the IEVGEN’S AX BLOG, there are many disadvantages of using lookup on FormControlString. They are as follows:

  • If user add add new control using personalization, the overridden logic would not any more.
  • If several controls are refereing to the same data source, the code and work have to be duplicated.

I had also uploaded a video tutorial on my YouTube channel. In that video, I have discussed a very easy and best approach to create form, automatic lookup and implement clicked() method of button in Microsoft D365FO. Sometimes, it may not fulfill your complex business requirement.

So, I have shared a video tutorial on how to create lookup in form data source field in D365FO. And in this tutorial, I will discuss about how to create lookup in form data source field in D365FO. You can also see the video.

Let’s Start!

  1. Create a table and name it as Moeen_LookupTable
  2. Add a string field and name it as PersonnelNumber and set StringSize as 20
  3. Create a form and name it as Moeen_LookupForm and use your custom table we have created in previous step as data source of form
  4. Set the pattern of form as Dialog – Basic
  5. Add the Group and set it’s pattern as Fields and field groups
    1. Add the PersonnelNumber field from data source to the Fields and field groups
    2. Set the Auto declaration to Yes for the PersonnelNumber FormControlString
  6. Add ButtonGroup and add two buttons in it
    1. Override the clicked() method of buttons
    2. Add the code in each button from here
    3. Set the Save record of property to No for both buttons
  7. Create two Classes with following names:
    1. Moeen_LookupFormEventHandler
    2. Moeen_LookupFormMethodOverrides
    3. Add the code in each class from here
  8. Build and synchronize the project
  9. Run your form and test your lookup

See the video: Click here

Download the complete project: Click here

Download the code: Click here

Blog: Click here

YouTube: Click here

GitHub: Click here

If you found any ambiguity or better solution. Please let me know. Moreover, if this helps you, please comment and share.

Don’t let small minds convince you that your dreams are too big.

0 POST COMMENT

Send Us A Message Here

Your email address will not be published. Required fields are marked *