function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Patrick DixonPatrick Dixon 

Moving Beyond Point-and-Click App Development - cancel button problem

Running through the Recruitment app creation in the Force.com Platform Fundamentals I have come across a problem.

 

Using the Mass Update Button created on the Job Applications related list, I find that pressing cancel produces an error message:-

core.apexpages.exceptions.ApexPagesHandledException: Filter Id value 00BA0000005siUC is not valid for the Job_Application__c standard controller

 

Obviously the Job_application__c standard controller is system generated, and the VF page is:-

 

<apex:page standardController="Job_Application__c" recordSetVar="applications">
    <apex:sectionHeader title="Mass Update the Status of Job Applications"/>
    <apex:form >
        <apex:pageBlock >
            <apex:pageMessages />
            <apex:pageBlockButtons >
                <apex:commandButton value="Save" action="{!save}"/>
                <apex:commandButton value="Cancel" action="{!cancel}"/>
            </apex:pageBlockButtons>
            <apex:pageBlockSection title="Status Update" collapsible="false">
                <apex:inputField value="{!Job_Application__c.Status__c}"/>
            </apex:pageBlockSection>
            <apex:pageBlockSection title="Selected Job Applications" columns="1">
                <apex:pageBlockTable value="{!selected}" var="application">
                    <apex:column value="{!application.name}"/>
                    <apex:column value="{!application.position__r.name}"/>
                    <apex:column headerValue="Candidate Name">
                        <apex:outputText value="{!application.candidate__r.First_Name__c &
                            ' ' &
                            application.candidate__r.Last_Name__c}"/>
                    </apex:column>
                    <apex:column value="{!application.Status__c}"/>
                </apex:pageBlockTable>
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>

 

- ie as per the salesforce documment.

 

So what's going on?  Is this a salesforce bug, or am I doing something wrong here (not correctly invoking the 'cancel' method)?

Best Answer chosen by Admin (Salesforce Developers) 
sebcossebcos

Hi,

the standard controller and the standardset controller are "autogenerated" by the system but you can extend them via Apex (controller extensions).

The standard controller is available when you use only the standardcontroller  attribute in the apex page tag.

When you add the recordsetvar keyword a standard set controller is available: a list of records.

In your case the list of records is the selection of job apps that you made in the Position page.

I have tweaked a bit the page so the cancel will work.

 

<apex:page standardController="Job_Application__c" recordSetVar="applications">
    <apex:sectionHeader title="Mass Update the Status of Job Applications"/>
    
    <apex:form >
        <apex:pageBlock >
            <apex:pageMessages />
            <apex:pageBlockButtons >
                <apex:commandButton value="Save" action="{!save}"/>
                <apex:outputLink value="/{!selected[0].Position__c}" style="text-decoration: none" styleClass="btn"> Cancel </apex:outputLink>
            </apex:pageBlockButtons>
            <apex:pageBlockSection title="Status Update" collapsible="false">
                <apex:inputField value="{!Job_Application__c.Status__c}"/>
            </apex:pageBlockSection>
            <apex:pageBlockSection title="Selected Job Applications" columns="1">
                <apex:pageBlockTable value="{!selected}" var="application">
                    <apex:column value="{!application.name}"/>
                    <apex:column value="{!application.position__r.name}"/>
                    <apex:column headerValue="Candidate Name">
                        <apex:outputText value="{!application.candidate__r.First_Name__c &
                            ' ' &
                            application.candidate__r.Last_Name__c}"/>
                    </apex:column>
                    <apex:column value="{!application.Status__c}"/>
                </apex:pageBlockTable>
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>

 The selected property gives you access to the list of records and what I do there is use the first element's Position id to return to the correct page once cancel is pressed: /selected[0].position__c is a URL that salesforce interprets as "go to that record with id <15 digit-id>"  

The example is not correct or highlights a bug. Just in case, I have logged a case for the documentation. You can do that by scrolling down in each documentation page to the box which says "Was this information useful?" .

 

All Answers

sebcossebcos

Hi,

I believe the example is not correctly using the standard set controller and the standard controller. 

If you comment out the line where you refer to the standard controller:

 

<apex:pageBlockSection title="Status Update" collapsible="false">
  <!--apex:inputField value="{!Job_Application__c.Status__c}"/-->
</apex:pageBlockSection>

the cancel button works correctly again. You can either use the standard controller or the standard set controller in a page not both.

I understand though that you want to do a mass update of the status field.

If you want to see how to do it, please see this example from the Visualforce developer guide:

http://www.salesforce.com/us/developer/docs/pages/index_Left.htm#StartTopic=Content/pages_controller_sosc_custom_button.htm 

 

I would adapt your page to use the example above. The cancel button in that case works as expected.

 

 

 

 

 

 

 

Patrick DixonPatrick Dixon

Thanks for the reply.

 

The mass update Status input field is obviously where the problem lies, but the code you refer to isn't a mass status update example so I'm not sure how I can use it?  I don't know what you mean by "standard controller or the standard set controller" either!  I have no access to the controller code as it seems to be system generated for a custom object.

 

The code I have used is directly from the Salesforce documentation suitable for people who don't know Apex programming, so the documentation needs sorting out somewhere.

 

I have no problem with the 'save' button, so I don't understand what the 'cancel' issue is.

sebcossebcos

Hi,

the standard controller and the standardset controller are "autogenerated" by the system but you can extend them via Apex (controller extensions).

The standard controller is available when you use only the standardcontroller  attribute in the apex page tag.

When you add the recordsetvar keyword a standard set controller is available: a list of records.

In your case the list of records is the selection of job apps that you made in the Position page.

I have tweaked a bit the page so the cancel will work.

 

<apex:page standardController="Job_Application__c" recordSetVar="applications">
    <apex:sectionHeader title="Mass Update the Status of Job Applications"/>
    
    <apex:form >
        <apex:pageBlock >
            <apex:pageMessages />
            <apex:pageBlockButtons >
                <apex:commandButton value="Save" action="{!save}"/>
                <apex:outputLink value="/{!selected[0].Position__c}" style="text-decoration: none" styleClass="btn"> Cancel </apex:outputLink>
            </apex:pageBlockButtons>
            <apex:pageBlockSection title="Status Update" collapsible="false">
                <apex:inputField value="{!Job_Application__c.Status__c}"/>
            </apex:pageBlockSection>
            <apex:pageBlockSection title="Selected Job Applications" columns="1">
                <apex:pageBlockTable value="{!selected}" var="application">
                    <apex:column value="{!application.name}"/>
                    <apex:column value="{!application.position__r.name}"/>
                    <apex:column headerValue="Candidate Name">
                        <apex:outputText value="{!application.candidate__r.First_Name__c &
                            ' ' &
                            application.candidate__r.Last_Name__c}"/>
                    </apex:column>
                    <apex:column value="{!application.Status__c}"/>
                </apex:pageBlockTable>
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>

 The selected property gives you access to the list of records and what I do there is use the first element's Position id to return to the correct page once cancel is pressed: /selected[0].position__c is a URL that salesforce interprets as "go to that record with id <15 digit-id>"  

The example is not correct or highlights a bug. Just in case, I have logged a case for the documentation. You can do that by scrolling down in each documentation page to the box which says "Was this information useful?" .

 

This was selected as the best answer
Patrick DixonPatrick Dixon

Thanks - that's very helpful.