13

I'm using a VF page and a controller to get the selected records in a view list and display some info. However the first time always fails (Related question), is there a different way to do this or a workaround to this bug (quite possible related to the Enhanced Session ID Management for Visualforce critical update)?

I'm using almost the same code as salesforce in their doc, so here is their code:

Class:

public class selectedSizeWorkaround {

    ApexPages.StandardSetController setCon;

    public selectedSizeWorkaround(ApexPages.StandardSetController controller) {
        setCon = controller;
    }

    public integer getMySelectedSize() {
        return setCon.getSelected().size();
    }
    public integer getMyRecordsSize() {
        return setCon.getRecords().size();
    }
}

Page:

<apex:page 
    standardController="Opportunity"
    recordSetVar="opportunities"
    extensions="selectedSizeWorkaround"
    showHeader="false"
    id="muopp"
>
    <apex:form id="muform">
        <apex:pageMessage 
            summary="Selected Collection Size: {!mySelectedSize}" 
            severity="info"
            id="mupms"
        />
        <apex:pageMessage
            summary="Record Set Size: {!myRecordsSize}"
            severity="info"
            id="mupmr"
        />
        <apex:pageBlock title="Opportunity Mass-Update" mode="edit" id="mub1">
            <apex:pageMessages />
            <apex:pageBlockSection id="mus1">
                <apex:inputField value="{!opportunity.stagename}" id="stagename">
                    <apex:actionSupport event="onchange" rerender="muselectedlist"/>
                </apex:inputField>
            </apex:pageBlockSection>
            <apex:pageBlockButtons location="bottom" id="mubut">
                <apex:commandButton value="Save" action="{!save}" id="butsav"/>
                <apex:commandButton value="Cancel" action="{!cancel}" id="butcan"/>
            </apex:pageBlockButtons>
        </apex:pageBlock>
        <apex:pageBlock title="Selected Opportunities" id="muselectedlist">
            <apex:pageBlockTable value="{!selected}" var="opp" id="mutab">
                <apex:column value="{!opp.name}" id="oppname"/>
                <apex:column value="{!opp.stagename}" id="oppstage"/>
            </apex:pageBlockTable>
        </apex:pageBlock>
    </apex:form>
</apex:page>
  • You are invoking the page from a list view button on the Account's Opportunity related list? Or something similar? – cropredy Oct 9 '14 at 21:45
  • If you're coming from a detail page, add an empty VF component and give it 0px width and height to hide it. – geeljire Oct 10 '14 at 0:39
  • Yes @crop1645, from a list view button. – Jose Oct 10 '14 at 0:54
  • It's not tested by me but what if you try to set yet another redirect executed only one time. Session will become valid and perhaps you'll get your selected records as expected. To ensure that redirect is executed only one time you can add a parameter/flag to the URL – Marcin Sz. Oct 15 '14 at 10:05
9
+25

Unfortunately, I don't have an answer for you in terms of a workaround.

I did spend some time trying to figure this out because I have a package that makes use of getSelected() on a list view and is in use in lots of orgs so was/am concerned about this breaking too.

I'm now of the opinion that the problem is org specific. Here are the tests that I performed:

  1. Your code in new DE Org --> failed
  2. Your code in new DE Org against my custom Object --> failed
  3. My code (unmanaged) in new DE Org against my custom Object --> failed
  4. My code (managed) in new DE Org against my custom Object --> failed
  5. Your code in my original DE Org for my package --> passed!
  6. My code in my original DE Org for my package --> passed (obviously)

Where your code = that in the OP and my code = that in my package that is in use in lots of orgs.

The pod that worked is EU1 whereas the one that failed is EU3. Any idea what pod you are on? I would say we have between 30 and 50 customers using this package and no one has reported this issue yet (though it does redirect you to the list view so the user may just not realise and think they did something wrong).

I will be creating a case with Salesforce.

Update: problem seems to be fixed now that DE org is upgraded to Winter '15, however it seems that the getRecords().size() is not returning the correct number, at least on EU3.

Update 2: now getSelected() doesn't seem to be working on EU1 since Winter '15 upgrade. Doh!

Update 3: 2 bugs created, currently scheduled for fix in Spring '15.

  • Yes, that's probably what's happening to the end user. Please let me know how your case goes. – Jose Oct 14 '14 at 21:14
  • Update: Salesforce have reproduced the issue and are investigating further. – Phil Hawthorn Oct 17 '14 at 10:24
  • @PhilHawthorn Could you please add a link to the SFDC defect? I scanned success.salesforce.com/issues_index but could not find a defect that matched. – SeanW Nov 10 '14 at 18:01
  • @SeanW - they raised two: W-2417273 and W-2414342 – Phil Hawthorn Nov 10 '14 at 19:49
-2

What are W-2417273 and W-2414342?

We had a similar issue and after logging a case, SFDC enabled a permission: "Skip immediate expiration of temporary sessions" and that resolved the issue for now. They told us that they are still looking for a permanent fix, but you should try changing that permission or contacting support in the mean time.

  • Please reword this more in the form of an answer, rather than a question with what seems like a possible answer – cropredy Nov 11 '14 at 1:37
  • They are reference numbers supplied by SF support, no idea what they actually are – Phil Hawthorn Nov 12 '14 at 20:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.