Hello, I am new in Business Central extension development and I want to create a multi-select lookup/dropdown field on Business Central Page. I want this field as party list in CRM used to specify many email addresses.
I used the following code on a page field but it only selects one row from the lookup table at a time.
This was close but was missing one line of code...
You need the GetSelectionFilter which returns the IDs separated by "|" (or) and pass it to the rec via the setfilter.
if contactpage.RunModal() = Action::LookupOK then begin contactpage.getrecord(contactRec); contactRec.setfilter("No.", contactPage.GetSelectionFilter()); "Send To" := ''; if contactRec.findset(false, false) then repeat if contactRec."E-Mail" <> '' then "Send To" = contactRec."E-Mail" ';'; until contactRec.next = 0; CurrPage.Update(); end;
something along this line. the code will not work as it is. adjust it according to what you need.
EmailPage.Lookup(true);
if emailpage.runmodal = action::lookupok then begin
result := '';
emailpage.getrecord(emailrec);
if emailrec.findset then
repeat
result := result + ',' + emailrec."email";
until emailrec.next = 0;
end;
Did you get the solution?
Thanks, Teddy Herryanto,
How can we achieve this through AL code?
After selecting from the dropdown/Lookup, I want selected email addresses in the input field like this:
emailId1@ymail.com, emailId2@gmail.com, emailId3@gmail.com
can you please post some AL code?
The standard lookup can only handle one record.
If you want to select multiple records, you need to handle it yourself in code ( calling the page, getrecord from page, assign it, etc).
This kind of selection is difficult to realise from a database design point of view.
(How would you save a multi-selection in a single row?)
A multi-selection is a 1:N relation. You must create a new table to store the Email addresses.