Tuesday, January 21, 2014

CRM 2013 : Change default entity for a Lookup field

This is an UNSUPPORTED customization and may break your customization's (while installing further roll-up's). Shared just for learning purpose and not recommended to use in any CRM environment.

Recently we upgraded a CRM 2011 environment to CRM 2013 and found that the JavaScript code written to filter the list of available entities in the lookup control (of type ActivityParty and Customer) didn't work, while the same was working good in CRM 2011. 

We expected 'document.getElementById("to").setAttribute()' to work as expected, but it didn't work as expected, rather it also didn't throw any script errors too. Will analyzing more we found that CRM 2013 form structure is driven by series of div components in order to improve performance. 

Then finally identified 'document.getElementById("to_i").setAttribute()' div was available and tired to use it, and surprisingly it worked. Below is the code snippet which helped to filter entities in CRM 2013 lookup fields.

Note: This is an identified bug in CRM 2013 and reported to Microsoft. We can expect the fix for the same in the coming Rollup's.

1 comment:

  1. hi Vinoth

    Do you think above code is supported? in upcoming roll-ups? can we achieve this using plugins. Thanks