D365FO - Create a multi-select lookup in batch jobs

D365FO - Create a multi-select lookup in batch jobs

In this article, I will be describing how we can create a multi-select lookup for display within the batch job dialog.

Contract class

  • Create a new variable of type 'List'. This will store the selected values of the user for the dropdown from the dialog.
  • Create a parm method to access the new list object
  • Ensure to specify the DataMember attribute
  • Add an appropriate label
  • Specify the data type for the list's content
  • Ensure to specify the DataContract and SysOperationContactProcessing attributes above the class declaration. An UI builder is also required. The requirements for this is explained in the next section.
Example:

UI builder class

  • Create an UI builder class that extends SrsReportDataContractUIBuilder
  • Add a new variable of type 'DialogField'. This will be displayed on the UI for user.
  • Implement the postBuild method. Initialize the contract from this.dataContractObject() and bind the dialog field variable to the contracts parm method created in previous section.
  • Implement the postRun method. Create your query for lookup and a container to store the selected fields. Pass the query, dialog field control, form run and selected fields container to the SysLookupMultiSelectCtrl control class.
Example:

Service class

  • Create service class that extends SysOperationServiceBase
  • Access the selected items list from the contract class
  • Write your query and access each value from the dropdown to add to your range, if required
  • Process your query
Example:

This is all that is required to add a multi-select lookup. You can access the service class within your controller as is normally done and run your batch job in front end to view the result. 

This is how the field would like





Comments

Popular posts from this blog

Generate and download a csv file using X++

Creating a batch job with query based filter in D365 back-office