+ Start a Discussion
KNKKNK 

Variable doesnot exist

Hi Team,

 

I have a requirement if Lawn and Garden field is true then the below select option needs to display.

 

 

Please help me, it is throwing variable doesnt exist.

 

private transient List<SelectOption> cacheProductFamilies = null;
    global List<SelectOption> productFamilies
    { 
        get {
            if (cacheProductFamilies==null){
                cacheProductFamilies = newSelectList(false);
                cacheProductFamilies.add(new SelectOption('CP','CP'));
                cacheProductFamilies.add(new SelectOption('Seeds','Seeds'));

  if (Account__r.Lawn_and_Garden_Agent__c==true){
                cacheProductFamilies.add(new SelectOption('Lawn and Garden','Lawn and Garden'));

}
            }
            return cacheProductFamilies;           
        }
    }
   
    global boolean readyForSearch {
        get {
            return selectedProductFamily!=null;
        }
    }

 

 

 

 

sfdcfoxsfdcfox

Account__r isn't a valid variable name. You probably meant to reference some instance of another record that is loaded on the page, probably through the standard controller. If so, you need this:

 

public ClassName(ApexPages.StandardController controller) { // Page constructor
  myRecord = (EntityName)controller.getRecord(); // Type of sobject you're using goes in EntityName
  // Also, you need a private variable called myRecord (for example).
}

 

KNKKNK
private transient List<SelectOption> cacheProductFamilies = null;
global List<SelectOption> productFamilies
{
get {
if (cacheProductFamilies==null){
cacheProductFamilies = newSelectList(false);
cacheProductFamilies.add(new SelectOption('CP','CP'));
cacheProductFamilies.add(new SelectOption('Seeds','Seeds'));
cacheProductFamilies.add(new SelectOption('Lawn and Garden','Lawn and Garden', (!lng.Lawn_and_Garden_Agent__c==true))); // Updated by Naresh_kalahasthi@infosys.com for Lawn and Garden products
}
return cacheProductFamilies;
}
}

global boolean readyForSearch {
get {
return selectedProductFamily!=null;
}
}

Getting Attempt to de-reference a null object at modified line.
Jeff MayJeff May

where are you setting the lng object?