In a previous blog post of mine I showed how to filter the N:N Add Existing button in CRM 2011. Since the upgrade to CRM 2013, this no longer works. Given that the code was unsupported, this was expected. Since CRM 2013 has changed the UI, the method in which N:N’s work has also changed.
The new function is called ‘LookupObjectsWithCallback’, and is exactly the same as the old function, except that it takes a callback function as the first parameter. I’ve pulled apart the CRM functions, and reconstructed them into my own function, which allows us to pass in a custom view as the default.
The new updated code is below:
The changes are mostly to the first function, however the second function has also been updated to pass 'this' into the other function. For this example, I have created a N:N between Account and Contact, and am filtering the ‘Contact’ view from the Account side to show only contacts with a first name of ‘Paul’.
For step by step instructions on how to customize the ribbon to get this working, check out the 2011 post, which has not changed:
You will also need the Ribbon Workbench for CRM 2013.
Note that this method uses the old popup window where you select multiple records at once, rather than the new CRM 2013 inline lookup where you select 1 at a time (personally I prefer the pop-up). This functionality is still unsupported, and is likely to break with any major updates.