1

I need to add a detail button to the Lead page to provide data entry for a custom child object ( Interest_Criteria__c ).

In my controller extension I have:

public class NewCriteriaControllerExtension {
private final Lead aLead;

public NewCriteriaControllerExtension(ApexPages.StandardController stdController) {

 this.aLead = (Lead)stdController.getRecord();
 string LandSF='';
 String LandAcres='';
}

public void CreateNewIC(){
    InterestCriteria__c InterestCriteria;
    InterestCriteria.Land_Acres__c=decimal.valueof(LandAcres);
    InterestCriteria.Land_SF__c=decimal.valueof(LandSF);
    InterestCriteria.LeadID__c=LEADIDFromLeadDetailPage;

    insert InterestCriteria;
}
}

And in VF:

<apex:inputtext id="LandAcres" size="10" value="{!LandAcres}"/> 

The compiler doesn't recognize standardcontroller.LandAcres so...

  1. What should an inputbox look like and how do I define any relevant variables?
  2. Because I need to access this VF page from a button on the lead detail, I assume I need to use a controller extension class, but please advise otherwise.
0
  1. Since you are accessing Controller attributes from VFP, so you need to declare them as public getter setter

  2. Standard Controller extension is good here which will respect the sharing and you will add additional functionalities in VFP and controller.

Code:

public class NewCriteriaControllerExtension {
private final Lead aLead;
public String LandSF {get;set;}
public String LandAcres {get;set;}

public NewCriteriaControllerExtension(ApexPages.StandardController stdController) {

 this.aLead = (Lead)stdController.getRecord();

}

    public void CreateNewIC(){
    InterestCriteria__c InterestCriteria = new InterestCriteria();

    InterestCriteria.Land_Acres__c=decimal.valueof(LandAcres);
    InterestCriteria.Land_SF__c=decimal.valueof(LandSF);
    InterestCriteria.LeadID__c=LEADIDFromLeadDetailPage;

    insert InterestCriteria;
    }
}
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.