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
joemurjoemur 

Checkbox Does Not Save to Custom Object

I have created a custom object and within the object i have some checkbox fields.
I am trying to add the field to the edit screen so that when the box is checked, it updates the field in the object after the save is pressed.
The save does not occur.
Any Ideas why the data will not save?   I have other inputFields that save just fine.
<apex:page standardController="CEG_Proposal_Letter__c" extensions="CEG_PL" showHeader="true" tabStyle="CEG_Proposal_Letter__c" action="{!checkForNullID}" >
<apex:form >
<apex:pageBlock title="CEG Proposal Pricing Quote Selection" >
<apex:pageBlockSection columns="2"> 
<apex:inputCheckbox value="{!CEG_Proposal_Letter__c.Mid_Term_Option_Selected_1__c}" label="Mid Term Select" />
</apex:pageBlockSection>
</apex:pageBlock>
    </apex:form>
</apex:page>
Best Answer chosen by joemur
joemurjoemur
If you are referring to the StandardController, this is the controller that is created when I created the customObject and I don't have (or at least know how to get to) the code for that. If you are talking about the extension controller, here it is: public class CEG_PL { //public Opportunity oppty = new Opportunity(); //public Account acct = new Account(); private final CEG_Proposal_Letter__c pl; public CEG_PL(ApexPages.StandardController stdController) { this.pl = (CEG_Proposal_Letter__c)stdController.getRecord(); //oppty = [select id, name, st_id_1__c, st_id_2__c from opportunity where opportunity.id = :ApexPages.currentPage().getParameters().get('Opportunity_id__c')]; //acct = [select id,name from account where account.id = :oppty.accountid]; } public string getPLID() { return pl.id; } public boolean getAppDeposit_Selected_1() { return pl.AppDeposit_Selected_1__c; } public void setAppDepositSelected_1(boolean datain) { pl.AppDeposit_Selected_1__c = datain; } public PageReference checkForNullID() { if (pl.id == null) { insert pl; Pagereference ref = new Pagereference('/apex/CEG_Proposal_Letter_New'); ref.getParameters().put('id',pl.id); ref.setRedirect(true); return ref; } return null; } public PageReference ReturnToOppty() { return new PageReference('/' + ApexPages.currentPage().getParameters().get('id')); } public PageReference CreateCEGProposalPDF() { Pagereference ref = new Pagereference('/apex/CEG_PROPOSAL_DOC'); //string strID = '/apex/SBG_DOC_Request?id=' + (string)ApexPages.currentPage().getParameters().get('id'); ref.getParameters().put('id',ApexPages.currentPage().getParameters().get('opportunity_id__c')); ref.setRedirect(true); return ref; } } Best Joseph Murawski Business Ops Analyst U.S. Bancorp Equipment Finance 503-603-2902 Joseph.Murawski@USBank.com

All Answers

GauravGargGauravGarg
Hi Joe,

Can you please post controller code. 

Thanks,
Gaurav
Skype: gaurav62990
joemurjoemur
If you are referring to the StandardController, this is the controller that is created when I created the customObject and I don't have (or at least know how to get to) the code for that. If you are talking about the extension controller, here it is: public class CEG_PL { //public Opportunity oppty = new Opportunity(); //public Account acct = new Account(); private final CEG_Proposal_Letter__c pl; public CEG_PL(ApexPages.StandardController stdController) { this.pl = (CEG_Proposal_Letter__c)stdController.getRecord(); //oppty = [select id, name, st_id_1__c, st_id_2__c from opportunity where opportunity.id = :ApexPages.currentPage().getParameters().get('Opportunity_id__c')]; //acct = [select id,name from account where account.id = :oppty.accountid]; } public string getPLID() { return pl.id; } public boolean getAppDeposit_Selected_1() { return pl.AppDeposit_Selected_1__c; } public void setAppDepositSelected_1(boolean datain) { pl.AppDeposit_Selected_1__c = datain; } public PageReference checkForNullID() { if (pl.id == null) { insert pl; Pagereference ref = new Pagereference('/apex/CEG_Proposal_Letter_New'); ref.getParameters().put('id',pl.id); ref.setRedirect(true); return ref; } return null; } public PageReference ReturnToOppty() { return new PageReference('/' + ApexPages.currentPage().getParameters().get('id')); } public PageReference CreateCEGProposalPDF() { Pagereference ref = new Pagereference('/apex/CEG_PROPOSAL_DOC'); //string strID = '/apex/SBG_DOC_Request?id=' + (string)ApexPages.currentPage().getParameters().get('id'); ref.getParameters().put('id',ApexPages.currentPage().getParameters().get('opportunity_id__c')); ref.setRedirect(true); return ref; } } Best Joseph Murawski Business Ops Analyst U.S. Bancorp Equipment Finance 503-603-2902 Joseph.Murawski@USBank.com
This was selected as the best answer
joemurjoemur
Figured out the action="{!checkForNullID}" is causing the problem.  I created a mirror page that does not contain the action and the checkboxes save just fine.