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
benkurianbenkurian 

passing getter setter methods to inner class

Hi All,

 

I have a code with setter and getter method like below mentioned and i need to pass this method to inner class for getting the 'selectValue' in query string.Iam new to apex coding and please help me as soon as possible.Thanks in advance

 

public class outerclass{

public string selectvalue{get;set;} // iam using this getter and setter method  here.  while  running the code is showing an error with selectvalue is not defined.

public class innerclass1{

public Boolean success;
public String errorMessage;

}

public class innerclass2{

public String sobjname;
public String fields;

}

 @RemoteAction
 public static  innerclass1 query(innerclass2 qobj) {

 innerclass1 resp = new innerclass1();

 String qstr = 'SELECT' + qobj.fields + 'FROM ' + qobj.sobjname + ' WHERE Deal_Name__c = \'' + selectValue + '\'' ;

try {
          for (List<SObject> rlit : Database.query(qstr)) {
                for (SObject rit : rlit) {
                    if ((current_result >= qobj.start) && (current_result < (qobj.start + qobj.recordCount))) {
                        resp.records.add(rit);
                    }
                    current_result++;
                }
            }
        } catch (Exception e) {
            resp.success = false;
            resp.records = null;
            resp.errorMessage = e.getMessage();
            return resp;
        }
        return resp;

}

}

hitesh90hitesh90

Hi,

 

You can use only static variable inside static method.

you have to use

 

public static string selectvalue{get;set;}

 

instead of

public string selectvalue{get;set;}

 

Important :
Hit Kudos if this provides you with useful information and if this is what you where looking for then please mark it as a solution for other benefits.

Thank You,
Hitesh Patel
SFDC Certified Developer & Administrator & Advanced Administrator & Sales cloud consultant
My Blog:- http://mrjavascript.blogspot.in/