I'm using a VF page to show Contacts. I have a group of categories (related lists) which are checked or unchecked. When I perform an action on the page, e.g. View, Edit, New, I want SF to remember which categories are checked, and check them again when the user clicks the back button or saves the record.
To do this, I'm setting retUrl and saveUrl where necessary, adding a parameter "rels" onto both which holds the keyPrefixes of the checked related lists. E.g. /apex/MyApexPage?id=003xxxxxxxxxx&rels=a09,a0B,a0K
Here is the code I'm using for this:
<apex:outputLink value="/{!fvv.recordId}/e?retURL={!URLENCODE('/apex/Codi?id='& contact.Id & '&rels='& preSelectedRelListsKeyPrefix &'')}&saveURL={!URLENCODE('/apex/Codi?id='& contact.Id & '&rels='& preSelectedRelListsKeyPrefix &'')}">Edit</apex:outputLink>
When I hover over the links I see the correct retURL and saveURL. This means that preSelectedRelListsKeyPrefix is populating correctly.
In the next page I see the Encoded URLs, i.e.
When I click the back button, I look for the rels parameter in my controller. However, this is null. In the URL rels is missing as well.
However, the weird thing is that it works if I perform an action in the page. Let's say I edit an object in the a0G related List. So the URL I generate would be the same as above.
. Now, if I edit the record, the rels parameter is correctly set, and the salesforce 'newid' parameter is attached, like so: https://na1.visual.force.com/apex/Codi?id=003U000000PL9LNIA1&rels=a0G&newid=a0GU0000005nFJR . But if I click the back button without editing, it doesn't work. And yet I checked for differences between my saveUrl code and my retUrl code and they are identical.
Likewise, the "New" and "View" buttons are not passing the parameter properly. I'm kind of stuck what to do here, since I'm passing everything correctly from my side and it seems to be salesforce that doesn't attach the parameter on the way back.