One of the differences between the CRM 2011 and CRM 2013 systems is how you can filter views. In 2013, new functionality was brought in that allows you to pre-filter from the columns currently existing in default view. This works really well when you don’t have a complex query from which to gather data from.
If your fetch XML includes a link entity it will not work because you can’t filter from columns that aren’t in the view yet.
The solution for this or if you have a complex fetch query and you use the 2011 version. This version allows you to gather data from multiple tables and return it to one custom view. You are also able to set this custom view as the default view.
And if one were so inclined, they could set the custom view as default and then do the custom pre-filter search from that.
For a project we were working on, we had a field that was of type account look up and our customer wanted to populate that view with alternate bill-to accounts for the customer on the form.
Because this query involves two link entities, we weren’t able to use the 2013 version because we were trying to filter a column that wasn’t yet in the view.
Also, given the complex nature of the fetch query we weren’t able to create a system view from which to filter off of.
So we used a solution introduced in 2011, by which we wrote the fetch query, the layout XML and added that as a custom view to the look up field.
Now when you do the lookup, the results are filtered by every account listed as alternative bill to account for the customer.
Here is the code you will need:
function preFilterLookup() { |
Suggested
- More blogs by Brian McLeod
- The Datix Blog
- Meet our Consultants
- Learn more about Microsoft Dynamics CRM