Microsoft Dynamics CRM 2011–”Microsoft Dynamics CRM has encountered an error” – Lookup Error
Posting the resolution to an issue found during UAT of a CRM 2011 system. The issue arose when the tester clicked save and close on a CRM 2011 record. The error message presented to the tester is shown below.
To view the error details, the user can click View the data that will be sent to Microsoft link. The error information relating to this post will look similar to the following screenshot.
The error message is:
<Message>‘this.$E_2.contentWindow.document.body’ is null or not an object</Message>
Also notice that is commonly appears on line 6.
Issue
When you enter data in a CRM 2011 lookup field that has the field formatting option of most recently used items functionality enabled, you receive a script error when clicking Save and Close on the CRM form.
Resolution
1. Go to Settings > Customization, and then click Customize the System.
2. Open your CRM 2011 entity in question, and then click Forms.
3. Double-click the form so the form customization window opens.
What you will need to do now for each custom lookup fields is the following:
4. Double-click to open.
5. Under Field Behaviour section in the Display tab, deselect or un tick the option Disable most recently used items for this field.
Now save and publish your customisation. You should now notice the issue disappear.
Greg Olsen
Yellow Duck Guy
Thanks, this was really annonying me / users. In our case the lookup was used muliple times on a form.