You need to sign in to do that
Don't have an account?
Rachit Joshi
Not able to save opportunity stage name using wrapper class
I am trying to save opportunity fields using a controller.
But I am not able to save it.
Hers's the Controller:
Here's the Visualforce page:
But I am not able to save it.
Hers's the Controller:
public class APPSWeeklyReview { public List<Opportunity> OppList {get;set;} public String usrId {get;set;} public List<User> users { get; set; } public String accid { get; set; } /*public List<Opportunity> ListOpps = new List<Opportunity> ();*/ public List<OpportunityWrapper> OppWrap {get;set;} /*public Opportunity opportunities {get;set;}*/ /* NEXT STEPS: Now we have to Leverage the new lists : ListOpps && OppWrap to Update the opportunities on the page and also load the new page. */ public APPSWeeklyReview() { OppList = new List<Opportunity>(); OppWrap = new List<OpportunityWrapper>(); } public class OpportunityWrapper { public Opportunity op {get;set;} public OpportunityWrapper(Opportunity o){ op = o; } } public List<OpportunityWrapper> getOpportunityList(){ if(OppList == null){ OppList = setOpps.getRecords(); for(Opportunity op: OppList){ OppWrap.add(new OpportunityWrapper(op)); } } return OppWrap; } public ApexPages.StandardSetController setOpps { get{ setOpps = new ApexPages.StandardSetController(Database.getQueryLocator([select Name,AccountId,StageName,Owner.Name,Amount,Id,OwnerId from Opportunity where OwnerId =:usrid limit 1])); return setOpps; } set; } public List<Opportunity> getOpps() { return (List<Opportunity>) setOpps.getRecords(); } public ApexPages.StandardSetController setUsrs { get{ setUsrs = new ApexPages.StandardSetController(Database.getQueryLocator([select Name from User where IsActive = true order by FirstName limit 20000])); dashDetails(); return setUsrs; } set; } public List<User> getUsr () { return (List<User>) setUsrs.getRecords(); } public List<SelectOption> getItems() { List<selectOption> options = new List<selectOption>(); users = (List<User>) setUsrs.getRecords(); for (User u: users){ options.add(new SelectOption(u.Id,u.Name)); } dashDetails(); return options; } public PageReference save() { List<Opportunity> OppList = New List<Opportunity>(); //Loop through OppList for(OpportunityWrapper op: OppWrap){ System.Debug (op.op.Name); OppList.add(op.op); } update OppList ; /* return dashDetails();*/ PageReference updatedPage = Page.APPSOppReview; updatedPage.setRedirect(true); return updatedPage; } public PageReference dashDetails() { system.debug('--------'+usrid); OppList = (List<Opportunity>) setOpps.getRecords(); OppWrap = new List<OpportunityWrapper>(); for(Opportunity op: OppList){ OppWrap.add(new OpportunityWrapper(op)); } return null; } }
Here's the Visualforce page:
<apex:page sidebar="false" showHeader="false" controller="APPSWeeklyReview" > <apex:form > <apex:pageBlock title="{!MID(TEXT(NOW()-5/24 ),11,9)} (GMT) {!$User.FirstName} {!$User.LastName} is Viewing Opportunities" mode="edit" id="WeeklyReview"> <apex:outputpanel > <html> <head> <style> .col:nth-child(even){ background-color: #f2f2f2; } .scrollit { overflow:scroll; height:100%; } .col{ width: 100%; } .slis{ height: 100%; } </style> </head> </html> </apex:outputpanel> <apex:outputLabel value="Owner Selection: " ></apex:outputLabel> <apex:selectList id="accts" value="{!usrId}" size="1" title="Account" enabledClass="slis"> <apex:selectOptions value="{!Items}"/> <apex:actionSupport event="onchange" reRender="WeeklyReview" action="{!dashDetails}" status="actStatusId"> <apex:param name="myParam" value="{!accid}" /> </apex:actionSupport> </apex:selectList> <apex:pageBlockButtons location="both" > <apex:commandButton action="{!save}" value="Save" /> </apex:pageBlockButtons> <apex:pageblockSection columns="1" > <apex:pageBlockSectionItem > <apex:pageBlockTable value="{!OpportunityList}" var="op" rowClasses="col" id="subCat" > <apex:column headerValue="Opportunity Name" ><apex:outputLink value="/{!op.op.Id}">{!op.op.Name}</apex:outputLink></apex:column> <apex:column headerValue="StageName" > <apex:inputField value="{!op.op.StageName}"/></apex:column> </apex:pageBlockTable> </apex:pageBlockSectionItem> </apex:pageblockSection> </apex:pageblock> </apex:form> </apex:page>