Admin

Archive for April, 2014

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 old code relied on a CRM function ‘LookupObjects’, which returned the records the user selected from the lookup. Since 2013 now uses ‘light-box’ pop-ups, rather than browser pop-ups, the JavaScript cannot be halted while the user selects their records. Because of this, CRM now uses callback functions to continue processing after the user has selected records from the lookup.

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 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’.

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.