You need to sign in to do that
Don't have an account?
SalesforceLearner
Checkbox values are not saving when I save a record
Please help me on below one :
I created a custom edit page for Lead. I am displaying Opportunities on Lead based on some condition.
In the edit page i am displaying opportunities based on condition and check box to select. If a particular opportunity is choosen them it should display that opportunity name in text field.
So I am facing 2 issues
1. checkbox value is not saving in edit page it is showing as selected but after saving it is unchecked
2. How to update the field based on checkbox.
Here is my code :
Controller :
I created a custom edit page for Lead. I am displaying Opportunities on Lead based on some condition.
In the edit page i am displaying opportunities based on condition and check box to select. If a particular opportunity is choosen them it should display that opportunity name in text field.
So I am facing 2 issues
1. checkbox value is not saving in edit page it is showing as selected but after saving it is unchecked
2. How to update the field based on checkbox.
Here is my code :
<apex:pageBlockTable value="{!oppz}" var="o"> <apex:column > <apex:facet name="header" > Opportunity Name</apex:facet> {!o.name} </apex:column> <apex:column headerValue="Select"> <input type="checkbox" id="looped" onclick="enableDisable(this)" /></apex:column> </apex:pageBlockTable>
Controller :
public class LeadandOpportunities { public List<Opportunity> oppz; public boolean IsChecked {get; set;} //public Opportunity op; public Lead lead; public LeadandOpportunities (ApexPages.StandardController controller) { system.debug('##########################'); this.lead= (Lead)controller.getRecord(); IsChecked = false; } public List<Opportunity> getOppz() { Lead l = [Select id,Name,OwnerId FROM Lead where id =: this.lead.id]; system.debug('@@@@@@@@@@' +l); if (l.OwnerId== null) return null; oppz = [Select id, Name, Account.Name,Select__c, CloseDate, Amount, Type from Opportunity where OwnerId =: l.OwnerId]; System.debug('$$$$$$$' + oppz); return oppz; } }
And you dont have any method to save the opportunity. Default save button will not work here.
Find the link for wrapper class.
https://developer.salesforce.com/page/Wrapper_Class
Thanks,
Pramodh