Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Business Central forum

Create Multi Select Lookup on Business Central Page

(0) ShareShare
ReportReport
Posted on by

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.

field(SenderTo; ssc_sender_to_scalable)
{
ApplicationArea = All;
Lookup = true;
TableRelation = "Segment Line";
}
But I am unable to achieve this. How can I implement this functionality?
If the solution is creating control Add-In( javascript library for multi-selection), so How can we do this?
Please help me out as I have spent a lot of time on it but could not get through it. Thanks
Categories:
  • yannstlo Profile Picture
    116 on at
    RE: Create Multi Select Lookup on Business Central Page

    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;

  • Suggested answer
    Teddy Herryanto (That NAV Guy) Profile Picture
    13,643 Moderator on at
    RE: Create Multi Select Lookup on Business Central Page

    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;

  • Faizan Subhani Profile Picture
    5 on at
    RE: Create Multi Select Lookup on Business Central Page

    Did you get the solution?

  • Community Member Profile Picture
    on at
    RE: Create Multi Select Lookup on Business Central Page

    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?

  • Suggested answer
    Teddy Herryanto (That NAV Guy) Profile Picture
    13,643 Moderator on at
    RE: Create Multi Select Lookup on Business Central Page

    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).

  • Hannes Holst Profile Picture
    5,767 on at
    RE: Create Multi Select Lookup on Business Central Page

    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.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard > Business Central forum

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans