Adding lookup fields in Dynamics CRM forms is one of those features that has not changed much throughout the years. Although very convenient for most scenarios, it can be considered too clicky especially when data needs to be entered rapidly. Typically, you would need at least 3 clicks if the lookup record you are looking for is not one of the first 10 displayed:
Figure 1-Click 1
Figure 2- Click 2
Figure 3- Click 3
There are variations for this process but in essence, the data selection is not as easy as it could or should be. Certainly, not as easy as when we select from a dropdown. Since dropdowns are only shown for option-sets and we can’t use option-sets instead of lookup entities (see “So you think XRM coders are evil? …”), Donostek has come up with a configurable web-resource that allows presenting a lookup entity as a dropdown.
Figure 4- Lookup as a dropdown
Once configured, this web-resource is displayed on the form as a regular dropdown control; therefore, all searching techniques known to work on such type of control will apply and save users those annoying clicks. Besides, by using a drop-down control, there is another annoyance that is eliminated. Since there’s no hyperlink to the lookup record, users won’t accidentally click it and then open the form for that lookup record.
As Figure 4 shows, we have added two small buttons to the right of the dropdown. The first from left to right, will open the detail form of the selected lookup record. If no value has been selected –dropdown shows … – then the ‘open’ button will open the CRM form for the related lookup entity in ‘Create’ mode.
The second button, when clicked, will refresh the values in the dropdown control. This is useful in case any value(s) in the related lookup entity had changed (added, deleted or edited).
This web-resource is compatible with Dynamics CRM 2015 and 2016 on-prem and online.
Main Features
- Fully Configurable Supports OData filters and is sortable by any column from lookup entity.
- Dependent Lookups Supports interactive filtering when using multiple lookup fields that have a hierarchical dependency.
- Field Requirement Enforces field requirement rules, so if your lookup field is required it will display a notification if the value is missing.
- Field Security Aware Enforces field security templates.
- Responsive Design Will adapt to the users’ device.
Installation
- Import the provided solution.
- Publish All
- Import the license file (CSV) into entity “Donostek License”.
Placing the web-resource on a form
The lookup field that the web-resource will help display needs to be placed on the form and set visible to false (Hint: Make sure you place it at the bottom of the page or section since CRM will still use the space for the field even if it’s set to not visible).
Place the web-resource “dtk_entity_lookup_as_dropdown.html” on the form.
Web-resource Configuration[1]
For a stand-alone lookup field
Parameter 1 | Required | Lookup Entity Name (logical name) |
Parameter 2 | Required | Lookup Entity ID Field Name (schema name) |
Parameter 3 | Required | Lookup Entity Field To be Displayed (schema name) |
Parameter 4 | Required | Lookup Field on Form (logical name) |
Parameter 5 | Optional | Filter in OData syntax |
Parameter 6 | Optional | Lookup Field to Sort By (schema name) |
For dependent lookup fields (Parent)
Parameter 1 | Required | Lookup Entity Name (logical name) |
Parameter 2 | Required | Lookup Entity ID Field Name (schema name) |
Parameter 3 | Required | Lookup Entity Field To be Displayed (schema name) |
Parameter 4 | Required | Lookup Field on Form (logical name) |
Parameter 5 | Optional | Filter in OData syntax |
Parameter 6 | Optional | Lookup Field to Sort By (schema name) |
Parameter 7 | Required | Name of dependent web-resource (logical name) |
Parameter 8 | Required | Dependent Lookup Field on Form (logical name) |
For dependent lookup fields (Child)
Parameter 1 | Required | Lookup Entity Name (logical name) |
Parameter 2 | Required | Lookup Entity ID Field Name (schema name) |
Parameter 3 | Required | Lookup Entity Field To be Displayed (schema name) |
Parameter 4 | Required | Lookup Field on Form (logical name) |
Parameter 5 | Optional | Filter in OData syntax |
Parameter 6 | Optional | Lookup Field to Sort By (schema name) |
Parameter 7 | Empty | |
Parameter 8 | Required | Dependent Lookup Field on Form (logical name) |
Parameter 9 | Required | Dependent Entity Lookup Field Name (schema name) |
Find examples in Appendix A.
Generic Formatting
Make sure you give the web-resource a label and make it display on the form. Also, set the web-resource visible by default.
Figure 5- Web-resource format
Set the web-resource height to 2 rows, never to scroll and remove the border.
Figure 6- Web-resource layout
Final Notes
- This gadget is available only for Dynamics CRM forms for versions 2015 and 2016 On-Premise and Online.
- Since the OData syntax has changed from 2015 to 2016, if you currently have version 2015 and plan to upgrade to 2016, the configuration (parameter syntax) will need to be modified according to the examples shown in this article.
- The free version of this gadget can be requested at http://donostek.com/#contact. For pricing and purchase information, please check out http://donostek.com/#products.
Appendix A
Examples
(1) Stand-alone Lookup
Dynamics CRM 2015 | |
Entity | Opportunity |
Lookup Field | Parent Account |
Lookup Entity | Account |
Filter | Active accounts |
Sort | Account name |
Parameters | account,AccountId,Name,parentaccountid,filter=StateCode/Value eq 0,Name |
Dynamics CRM 2016 | |
Entity | Opportunity |
Lookup Field | Parent Account |
Lookup Entity | Account |
Filter | Active accounts |
Sort | Account name |
Parameters | account,accountid,name,parentaccountid,filter=statecode eq 0,name |
(2) Dependent Lookups
This example uses 2 custom entities – states (new_state) and cities (new_city). Custom fields relevant to this example: new_state.new_stateId, new_state.new_name, new_city.new_cityId, new_city.new_name, new_city.new_stateId, customeraddress.new_stateId, customeraddress.new_cityId.
Figure 7- Mini ER diagram
Parent, Dynamics CRM 2015 | |
Entity | Address |
Lookup Field | New State |
Lookup Entity | New State |
Filter | Active states |
Sort | State name |
Parameters | new_state,new_stateId,new_name,new_stateid,filter=statecode/Value eq 0,new_name,WebResource_City,new_cityid |
Child, Dynamics CRM 2015 | |
Entity | Address |
Lookup Field | New City |
Lookup Entity | New City |
Filter | Active cities |
Sort | City name |
Parameters | new_city,new_cityId,new_name,new_cityid,filter=statecode/Value eq 0,new_name,,new_stateid,new_stateId |
Note that the casing on this example –for Dynamics CRM 2015- is just for illustration purpose. You should ultimately use the exact casing as shown in the solution configuration interface:
Figure 8 – Getting the schema names
Parent, Dynamics CRM 2016 | |
Entity | Address |
Lookup Field | New State |
Lookup Entity | New State |
Filter | Active states |
Sort | State name |
Parameters | new_state,new_stateid,new_name,new_stateid,filter=statecode eq 0,new_name,WebResource_City,new_cityid |
Child, Dynamics CRM 2016 | |
Entity | Address |
Lookup Field | New City |
Lookup Entity | New City |
Filter | Active cities |
Sort | City name |
Parameters | new_city,new_cityid,new_name,new_cityid,filter=statecode eq 0,new_name,,new_stateid,_new_stateid_value[2] |
DISCLAIMER
THIS TOOL IS PROVIDED BY DONOSTEK LLC. “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL DONOSTEK LLC. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
For Dynamics CRM 2015, the parameters marked as “schema name” need to use the actual schema name (casing has to match exactly). For Dynamics CRM 2016, the parameters marked as “schema name” for the moment can use all lower case. If you need help with the OData syntax, you may want to use tools such as the CRM Rest Builder
.
Please be aware of the syntax for Parameter 9 in Dynamics CRM 2016 since it has changed from previous versions.