D365 FO Adding custom lookup query code X++
Purpose:
The purpose of this document is to demonstrate how we can create a lookup in X++
To add a lookup form to a control. To create a custom lookup form, you override the lookup method of the control. You can then create a query and lookup form you can use to populate the control. However, the lookup that appears is associated only with the specified control and is not available to any other control or form.
In the AOT, expand Forms, expand the form, expand Designs, right-click Design, click New Control, and then click StringEdit. A StringEdit control is added to the form.
Expand the control, right-click Methods, click Override method, and then click lookup. The lookup method opens in the code editor.
In this tutorial, we are going to make custom lookup using x++ for form in D365FO. Most people think that we have to put a lot of effort to make this happen, but, it is very easy. And some people got stuck on this because they don’t follow the steps. So, I need you to relax, make your focus correct and I need your concentration and obviously your appreciation too. Let’s start!
- Create a form
- Open the form
- Go to the form string control on which you want to show lookup
- Go to the events of the form string control on forms
- Right click the OnLookup event and click Copy event handler method
- Create a new class and paste the event handler method in the class you have copied in the previous step
- It would be like this:
Note:
- Form name: EcoResProductDetailsExtended
- Form string control name: MainAccount
- Add the logic of the lookup in the event handler method like below:
No comments:
Post a Comment