You need to sign in to do that
Don't have an account?
MrHammy
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!
You can achieve this just by using standard controller,
something like