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
AmphitriteAmphitrite 

Custom list controller Save method - not updating records

I've written a controller extension for a standardset controller driven Visualforce Page. I've include a custom 'Save and Close' button that saves the records and closes the page. However - it isn't updating the list I've called in the constructor. Here is the controller extension and vforce page - limited to just the basics - any assistance would be great.

 

 

Controller extension:

 

public with sharing class InEditExtensionOne {

//Global Variables
private ApexPages.StandardSetController controller;
Private final string InEditUser=UserInfo.getUserId();
public list<Case> InEdit { get; set; }
public String onClick { get; set; }

// Standard Controller Constructor
public InEditExtensionOne(ApexPages.StandardSetController Controller) {

this.controller = controller;
this.InEdit=[SELECT Id,CaseNumber,Account.Name,Account.Id,Description,Subject,ButtonClick__c FROM Case WHERE InEditUser__c =: InEditUser];

}



//Save and Close method


public PageReference SaveClose(){

for(Case g :InEdit){

g.ButtonClick__c=onClick;


}

update InEdit;



PageReference pageRef = new PageReference('/500/o');
pageRef.setRedirect(true);
return pageRef;

}

}

 

 

 

 

VForce Page

 

 

<apex:page standardController="Case" extensions="InEditExtensionOne"
recordSetVar="implementations">



<apex:sectionHeader title="New Field Values"/>
<apex:form >
<apex:pageBlock >
<apex:pageMessages />
<apex:pageBlockButtons >
<apex:commandButton value="Save and Close"
action="{!saveClose}" onclick="NoPrompt();"/>
<apex:commandButton value="Save and Next"
action="{!saveNext}" onclick="NoPrompt();"/>
</apex:pageBlockButtons>



<apex:pageBlockSection title="Input Fields" showHeader="false"
collapsible="false">

<apex:inputField value="{!Case.AccountId__c}"/>
<apex:inputField value="{!Case.Subject__c}"/>
<apex:inputTextArea value="{!Case.Description__c}" rows="5" cols="75"/>
<apex:inputField Label="ButtonClick" value=""{!onClick}">

</apex:pageBlockSection>



<apex:pageBlockSection title="Selected Implementations" columns="1">
<apex:pageBlockTable value="{!InEdit}"
var="c">

<apex:column headerValue="Case No">
<apex:outputLink value="/{!c.id}">{!c.casenumber}</apex:outputLink>
</apex:column>
<apex:column value="{!c.Account.Name}"/>
<apex:column value="{!c.Subject}"/>
<apex:column value="{!c.Description}"/>
<apex:column value="{!c.ButtonClick__c}"/>

</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>

sandeep@Salesforcesandeep@Salesforce
There might be some exception behind the screen so can you please use Try Catch and then return null error message gets displayed on page iteself ?

Thanks
Sandeep Singhal