web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Enable multiple select option in lookup dialog window and add to grid in CRM

(0) ShareShare
ReportReport
Posted on by 44

Hi,

How to enable multi select option on lookup dialog and then add to grid when add button in clicked using JavaScript.

I wrote code for this but its not working. It is showing single record lookup window and how to add that selected record to grid. 

 

function showLookupDialog(SelectedEntityTypeCode,SelectedControl) {

        try {
            debugger;
            var serverurl = Xrm.Page.context.getClientUrl();
            var DialogOptions = new Xrm.DialogOptions();
            DialogOptions.width = 600;
            DialogOptions.height = 600;
            //Change
            var objecttypecode = "";
            if (parent.Mscrm.XrmInternal.getEntityCode != null && parent.Mscrm.XrmInternal.getEntityCode != undefined)
                objecttypecode = parent.Mscrm.XrmInternal.getEntityCode("contact");
            else
                objecttypecode = parent.Mscrm.XrmInternal.prototype.getEntityCode("contact");
            var url = serverurl + "/_controls/lookup/lookupsingle.aspx?LookupStyle=multi&class=null&objecttypes=" + objecttypecode + "&browse=0&ShowNewButton=1&IsInlineMultiLookup=0&ShowPropButton=1&DefaultType=10015";
    
            Xrm.Internal.openDialog(urlDialogOptionsnullnullCallbackFunction);
        } catch (e) {
            alert(e.message);
    
        }
        function CallbackFunction(result){
            for (var i = 0i < result.items.lengthi++) {
                var id = result[i].id;
                
                
                


            }
            alert(result);
        }
}

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    ajyendra Profile Picture
    1,738 on at

     Hi,

    Replace this line to

    var url = serverurl + "/_controls/lookup/lookupsingle.aspx?LookupStyle=multi&class=null&objecttypes=" + objecttypecode + "&browse=0&ShowNewButton=1&IsInlineMultiLookup=0&ShowPropButton=1&DefaultType=10015";

    this

     var url = serverurl + "/_controls/lookup/lookupinfo.aspx?LookupStyle=multi&class=null&objecttypes=" + objecttypecode + "&browse=0&ShowNewButton=1&IsInlineMultiLookup=0&ShowPropButton=1&DefaultType=0"; // for contact the objecttypecode is 2 

    after this change you will able to do multiple record lookup window 

    Thanks

    Ajyendra

    If this answer is helpful.Please Mark as Verified.

  • Naeem Khan Profile Picture
    44 on at

    Hi,

    Thanks, its working. One more thing selected record are not being added to grid after add button is clicked. Do we have to implement logic for this or it gets added automatically.

    I think so we need to add code to add record to grid.

  • Suggested answer
    ajyendra Profile Picture
    1,738 on at

    Hi,

    No it will not add automatically . You have to update contact records company field . (In my case I am taken contact and account entity)
    For that you have to write a logic inside CallbackFunction which update record of contact company field. (In my case I am taken contact and account entity).

    Thanks
    Ajyendra

    If this answer is helpful.Please Mark as Verified.

  • Suggested answer
    Arun Vinoth Profile Picture
    11,615 Moderator on at

    The above code is totally unsupported as you are using internal methods & controls.

    Pls use the lookupObjects like answered in Stack Overflow: stackoverflow.com/.../7920473

    Xrm.Utility.lookupObjects(lookupOptions).then(successCallback, errorCallback)

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
ScottDurow Profile Picture

ScottDurow 2

#2
GJones Profile Picture

GJones 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans