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
skiptomylou11skiptomylou11 

Modify multiple records via one Visualforce page - Issue with Controller Extension

Dear all,

 

What I try to achieve is to have a visualforce page where a single field (Bid_Costs_Forecast_YE__c) can be updated for a number of records in a single step instead of going into each record individually.

 

The records in the VF page should be filtered and sorted by certain criteria .

 

Therefore I put in an extension. 

However, when I update the information in the VF page and click 'Save' the updates are not saved.

Any help on how the extension needs to be modified is highly appreciated.

 

Many thanks! 

 

<apex:page standardController="Project__c" recordSetVar="Projects__c" tabstyle="Project__c" sidebar="false" extensions="BidCostAmericasExt">
    <apex:form >  
        <apex:pageBlock title="Bid Costs Americas" >
        <apex:pageblockButtons >
           <apex:commandButton style=" height:25px; margin-left:400px; font-size:14px" action="{!quickSave}" value="Save" />
        </apex:pageblockButtons>
            <apex:pageBlockTable value="{!SYSProjects}" var="opp">          
                <apex:column headerValue="Project" > 
                     <apex:outputLink target="_blank" value="/{!opp.id}">{!opp.Name}</apex:outputLink>             
                </apex:column> 
                <apex:column headerValue="Priority" width="150px"> 
                    <apex:outputField value="{!opp.Priority__c}" />        
                </apex:column>    
                <apex:column headerValue="Actuals YTD" width="80px">
                    <apex:outputField value="{!opp.Bid_Costs_Actuals_YTD__c}" />
                </apex:column> 
                <apex:column headerValue="Budget YE" width="80px">
                    <apex:outputField value="{!opp.Bid_Costs_Budget_YE__c}" />
                </apex:column>   
                <apex:column headerValue="Forecast YE" width="80px">
                    <apex:inputField style="width:80px" value="{!opp.Bid_Costs_Forecast_YE__c}" />
                </apex:column>  
            </apex:pageBlockTable>  
        </apex:pageBlock>
    </apex:form>
</apex:page>

 

public class BidCostAmericasExt {

    public BidCostAmericasExt(ApexPages.StandardSetController controller) {

    }

    Project__c proj;
    
    public BidCostAmericasExt (ApexPages.StandardController controller) {
        proj = (Project__c) controller.getRecord();            
    }    
    
    public List<Project__c> getSYSProjects() {
        return [select name, Priority__c, Bid_Manager__c, Bid_Costs_Actuals_CTD_PY__c, Bid_Costs_Actuals_YTD__c, Bid_Costs_Budget_YE__c, Bid_Costs_Forecast_YE__c,  Comment_Bid_Costs__c from Project__c where Business_Unit__c = 'Americas' order by Bid_Costs_Forecast_YE__c];    
    }
}

 

 

 

NashalNashal

Hi,

 

You can do like this

 

public class BidCostAmericasExt {

public List<Project__c> proList {get; set;}


public BidCostAmericasExt(ApexPages.StandardSetController controller) { this.proList = [select name, Priority__c, Bid_Manager__c, Bid_Costs_Actuals_CTD_PY__c, Bid_Costs_Actuals_YTD__c, Bid_Costs_Budget_YE__c, Bid_Costs_Forecast_YE__c, Comment_Bid_Costs__c from Project__c where Business_Unit__c = 'Americas' order by Bid_Costs_Forecast_YE__c]; } public PageReference Savefn(){
update proList;
} }

apex:page standardController="Project__c" tabstyle="Project__c" sidebar="false" extensions="BidCostAmericasExt">
    <apex:form >  
        <apex:pageBlock title="Bid Costs Americas" >
        <apex:pageblockButtons >
           <apex:commandButton style=" height:25px; margin-left:400px; font-size:14px" action="{!saveFn}" value="Save" />
        </apex:pageblockButtons>
            <apex:pageBlockTable value="{!proList}" var="opp">          
                <apex:column headerValue="Project" > 
                     <apex:outputLink target="_blank" value="/{!opp.id}">{!opp.Name}</apex:outputLink>             
                </apex:column> 
                <apex:column headerValue="Priority" width="150px"> 
                    <apex:outputField value="{!opp.Priority__c}" />        
                </apex:column>    
                <apex:column headerValue="Actuals YTD" width="80px">
                    <apex:outputField value="{!opp.Bid_Costs_Actuals_YTD__c}" />
                </apex:column> 
                <apex:column headerValue="Budget YE" width="80px">
                    <apex:outputField value="{!opp.Bid_Costs_Budget_YE__c}" />
                </apex:column>   
                <apex:column headerValue="Forecast YE" width="80px">
                    <apex:inputField style="width:80px" value="{!opp.Bid_Costs_Forecast_YE__c}" />
                </apex:column>  
            </apex:pageBlockTable>  
        </apex:pageBlock>
    </apex:form>
</apex:page>