Implementing a Multi-Select Lookup Control in D365FO
Overview
In this document, we’ll walk through how to implement a custom multi-select lookup in a Dynamics 365 Finance and Operations form. Our scenario will use Purchase Requisition Header as an example, where a user needs to select multiple Department values.
We'll leverage the SysLookupMultiSelectCtrl
class for this implementation.
What is SysLookupMultiSelectCtrl
?
SysLookupMultiSelectCtrl
is a system class in D365FO used to create multi-select lookups on form controls. It provides three static methods to construct the control:
-
SysLookupMultiSelectCtrl::construct()
— uses an AOT query name. -
SysLookupMultiSelectCtrl::constructWithQuery()
— uses aQuery
object. -
SysLookupMultiSelectCtrl::constructWithQueryRun()
— uses aQueryRun
object.
Implementation Steps
1. Add Custom Field
Create a new field in the PurchReqTable
table named DaxDepartment
.
Add the newly created DaxDepartment
field to the PurchReqTable form.
3. Extend the PurchReqTable Form
Create a CoC (Chain of Command) extension for the PurchReqTable
form and add the following logic:
4. Extend the Form Data Source — active()
Method
Create a data source extension for PurchReqTable
and override the active()
method to populate the lookup with previously selected values:
5. Add Logic in the OnModified
Event
Handle the Modified
event on the field control to store the selected values:
UI Testing
Once implemented, build and synchronize the project. Then navigate to the Purchase Requisition form and test the DaxDepartment
field. You should see a multi-select lookup that allows choosing multiple department values.
You've now successfully implemented a multi-select lookup control on a D365FO form using SysLookupMultiSelectCtrl
. This dynamic and user-friendly approach enhances flexibility and usability within your business application.
Thanks,
Thiru. G
No comments:
Post a Comment