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
MrHammyMrHammy 

Display a list, make an edit and then save

it sounds so simple, get a list of similar items and allow the user to edit one field, then click save and return to where you came from. I just do not understand enough to make this happen, can some one take a look? When i hit save i get the page back but no updates have happened 

 

VF page 

 

<apex:page standardController="ERP_Data__c" extensions="opportunityList2Con">

    <apex:form >
        <apex:pageBlock title="{!erp.Chain__c}" >
            <apex:pageMessages />
            <apex:pageBlockButtons >
              <apex:commandButton value="Save" action="{!mysave}"/>
            </apex:pageBlockButtons>
            <apex:pageBlockTable value="{!Opportunities}" var="o" >
                
                <apex:column value="{!o.Account__c}"/>
                
                <apex:column value="{!o.id}"/>
                
                <apex:column value="{!o.Acct_RT_Name__c}"/>
              
                <apex:column headerValue="Program">
                
                    <apex:inputField value="{!o.Program__c}"/>
                    
                </apex:column>
                
            </apex:pageBlockTable>      
        </apex:pageBlock>
    </apex:form>
    
</apex:page>

 and the controler

 

public class opportunityList2Con {
public opportunityList2Con(ApexPages.StandardController controller) {}

erp_data__c erp;
public erp_data__c geterp() {
if (erp == null){                      
erp = [SELECT Chain__c FROM ERP_Data__c WHERE 
    id = :ApexPages.currentPage().getParameters().get('id')];
      }
   return erp;

}

String myTestString = ApexPages.currentPage().getParameters().get('name') ;

// ApexPages.StandardSetController must be instantiated
// for standard list controllers
public ApexPages.StandardSetController seterp {
     get {
        if(seterp == null) {
           return new ApexPages.StandardSetController(
                     Database.getQueryLocator(
                [SELECT name, Account__c ,Acct_RT_Name__c, Chain__c, 
                        Id, Program__c, RecordTypeId    
                 FROM ERP_Data__c  
                 WHERE Chain__c = :myTestString limit 25 ]));
        }
        return seterp;
    }
   set;
 }
 
 
 
 
// Initialize seterp and return a list of records
public list<ERP_Data__c> getOpportunities()  
{
return (list<ERP_Data__c>) seterp.getRecords();
}
public PageReference mysave(){

    seterp.save();  //call the save method on your set controller
    //controller.save();  add this if you want to save your original ERP_Data__c record         
    //as well
    
    
return null;

}
}

 Most of this code I have picked up and modified from other people projects so my understanding  on why some things are here is low. Once i get it working i will spend the time to clean up the naming spacing and comments , thanks in advance!

alibzafaralibzafar

You can achieve this just by using standard controller,  

 

something like

 

<apex:page standardController="Account" recordSetVar="accounts">
.
<apex:pageBlockButtons >
<apex:commandButton value="Save" action="{!save}"/>
<apex:commandButton value="Cancel" action="{!cancel}"/> 
</apex:pageBlockButtons>
.
 <apex:pageBlockTable value="{!selected}" var="s">
<apex:column headerValue="Custom Field">
 <apex:Inputfield value="{!s.CustomField__c}" /> 
</apex:column>
</apex:pageBlockTable>
.
.
.
</apex:page>