That one is extremely tricky. My customer had this sweet, short request: change the default view of related orders, in the contact entity.
By default, the defaule view is set to “Active”, and the customer wanted it to be “All”. How to do that? Well, here’s the answer below. It took me 5 hours to come up with this solution, but it works.
Highly unsupported if course…
Here’s the code below:
- I use jQuery to change the selected option in the picklist. However, and of course, this doesn’t change the displayed data. And, a call to refresh after changing this value, does not get the right data. It still retrieves only the active records. So to access jquery in this code, as we are in the context of an associated view, I use the ribbon trick (could also have deleted the js web resource directly and evaled it).
- I use a global variable, ouch. So I name it carefully.
- I replace the send function of the XMLHttpRequest object… That becomes sweet… 🙂 The point is to replace, in the message sent to the server, the statecode 0, by All, so that all records are retrieved, instead of the active ones.
- After the first pass, I reset the original send function, otherwise the replace will be applied to all subsequent queries, always retrieving all the records…
And here you go, a nice related view, with the default filter being set on ‘All’ !
That one is my pride. 🙂