Show Lookup Dialog in Dynamics 365 v9.0

By | June 27, 2018

Introduction:

In Dynamics 365 v9.0 Microsoft introduces new development feature in Dynamics 365 to show lookup dialog using Xrm.Utility.lookupObjects method.

Xrm.Internal.Opendialog is most commonly used method to open dialog where we need to provide URL. But this method is not supported in UCI or mobile app.

So, open a lookup window using JavaScript can be achieved using Xrm.Utility.lookupObjects method.

Parameters for Xrm.Utility.lookupObjects method is as follows:

  • entityTypes: provide list of the entities to be displayed.
  • defaultEntityType: Specify the default entity to be shown in lookup window.
  • defaultViewId: Specify the Guid of default view need to be displayed in lookup dialog.
  • allowMultiSelect: Specify whether want to allow user to select multiple records.
  • viewIds: Provide the list of views that need to be available for lookup dialog.

Consider, an example where we need to open html webresource, on html page there will be a textbox and button to select the contact. When user click on “Select Contact” button, the lookup dialog of contact will gets open which allows user to select contact.

Steps need to follow:

1. We need to create html page with textbox and “Select Contact” button.

2.  Next write a script for showing lookup dialog using Xrm.Utility.lookupObjects method.
3. Add ribbon button “Contact Details” on Account form. Add “openWeb” function onclick of the ribbon button.

Show Lookup Dialog in Dynamics 365

4. Now when we click on the contact lookup button it will open the “Contact Details” html page.

Show Lookup Dialog in Dynamics 365

5. This html page consist of a textbox and “Select Contact” button. When user click on the button, lookup dialog with default entity and default view provided in parameters of lookupObjects method gets open.

Show Lookup Dialog in Dynamics 365

6. In UCI or Mobile app it opens the lookup dialog as shown in below screenshot.

Show Lookup Dialog in Dynamics 365

Conclusion:

Using the new feature introduced in Microsoft Dynamics 365 user can show lookup dialog using Xrm.Utility.lookupObjects method.

Microsoft Dynamics CRM and QuickBooks Integration

Leave a Reply