You need to sign in to do that
Don't have an account?
Becky Miller 15
Need help with Default the Checkbox to Checked (VF and Apex Class)
I have a field on the OpportunityLineItem.To_Business_plan__c that I want when the product is selected it automatically defaults to checked on the Product Selector. I have highlighted the piece of code not working. Any help would be much appreciated.
APEX CLASS:
public with sharing class opportunityProductEntryExtension {
public Opportunity theOpp {get;set;}
public Opportunitylineitem opli {get;set;}
public String searchString {get;set;}
public List<OpportunityLineItemWrapper> shoppingCart {get;set;}
public List<PricebookEntry> availableProducts {get;set;}
public Pricebook2 theBook {get;set;}
public String toSelect {get; set;}
public String toUnselect {get; set;}
public Decimal Total {get;set;}
public Boolean overLimit {get;set;}
public Boolean multipleCurrencies {get; set;}
public with sharing class controller {
public list < opportunitylineitem> objb = [select to_business_plan__c from opportunitylineitem];
public list <opportunitylineitem> getRecords() {
if(objb <> null){
for(opportunitylineitem opli : objb){
opli.to_business_plan__c = true;
}
}
return objb;
}
}
VisualForce:
<apex:column headerValue="{!$ObjectType.OpportunityLineItem.Fields.To_Business_Plan__c.Label}">
<apex:inputCheckbox value="{!s.oli.To_Business_Plan__c}" id="objb"/>
</apex:column>
The page renders but the checkbox is not defaulting to checked.
APEX CLASS:
public with sharing class opportunityProductEntryExtension {
public Opportunity theOpp {get;set;}
public Opportunitylineitem opli {get;set;}
public String searchString {get;set;}
public List<OpportunityLineItemWrapper> shoppingCart {get;set;}
public List<PricebookEntry> availableProducts {get;set;}
public Pricebook2 theBook {get;set;}
public String toSelect {get; set;}
public String toUnselect {get; set;}
public Decimal Total {get;set;}
public Boolean overLimit {get;set;}
public Boolean multipleCurrencies {get; set;}
public with sharing class controller {
public list < opportunitylineitem> objb = [select to_business_plan__c from opportunitylineitem];
public list <opportunitylineitem> getRecords() {
if(objb <> null){
for(opportunitylineitem opli : objb){
opli.to_business_plan__c = true;
}
}
return objb;
}
}
VisualForce:
<apex:column headerValue="{!$ObjectType.OpportunityLineItem.Fields.To_Business_Plan__c.Label}">
<apex:inputCheckbox value="{!s.oli.To_Business_Plan__c}" id="objb"/>
</apex:column>
The page renders but the checkbox is not defaulting to checked.
Please try below modified code:
Let us know if that helps you.
Best Regards,
BALAJI.