Microsoft Dynamics 365 v9.0 was announced in July 2017. It is a major release, which has enhanced many existing features in CRM online and has also introduced new features.
The Xrm.Utility namespace, is one of the namespaces that has been enhanced with many new functions in Dynamics 365 version 9.0.
In this post, I will describe the lookupObjects function of the Xrm.Utility namespace.
Basically, the Xrm.Utility.lookupObjects function is used to open a lookup dialogue on the form, with the list of entities & views that you specify, when declaring the properties of lookupObjects.
Now, I will explain you how we can use the Xrm.Utility.lookupObjects function:-
Here I have an entity named “Employee”, with the two fields “Name” (Type : Single Line of Text) & “Hobbies” (Type : Multiple Lines of Text). And, on the change of the “Name” field, I will open a lookup dialogue, from where the user will select one or more records. Then finally, the selected records will be populated in the “Hobbies” field on the form.
1. ‘lookupOptions’ is an object that defines the options for opening the lookup dialogue.
2. Using ‘DefaultEntityType’, you can set the default selected entity in the lookup option.
3. ‘defaultViewId’ property will define the default view to use.
4. ‘viewIds’ is an array, where you can specify the views, that you want to show in the lookup.
5. ‘EntityTypes’ is an array, where you can specify the entities, that you want to show in the lookup.
6. ‘AllowMultiSelect’ property will define whether the user can select multiple records or not.
Here, in the above image you can see that, by default, the “Sports” entity is selected.
This is because, we have set the ‘defaultEntityType’ property of the lookupOptions object.
And the ‘defaultViewId’ property of the lookupOptions object have set “Active Sports”, as the default view.
Also, in the below image, you can see that, there are only 2 views, which have been displayed for Sports entity. This is because, we have set the ‘viewIds’ property of the lookupOptions object, with only some views that is required. In this way, you can restrict the user from selecting the records from the other views of the selected entity.
Now, you can select single or multiple records by selecting the check-box, beside the record, and then clicking on the Select Button.
You can also remove the selected records, by clicking on the record to be removed from the selection, and then clicking on the Remove Button.
Here, I have selected two records from the Sports Entity.
And, I have selected three records from the Technologies Entity.
After selecting all the required records, click on the Add Button. You will see that all the selected records are now displayed in the Hobbies field on the form:-
I Hope this helps you…
Insert data into Many-to-Many relationship in Dynamics CRM very easily & quickly, using the Drag and drop listbox.
© All Rights Reserved. Inkey Solutions 2018