+ Start a Discussion
Vetriselvan ManoharanVetriselvan Manoharan 

Setting public variable

Hi,

I am having a flag which is public variable in the class(with sharing). I am assigning values to that variable inside the constructor of that class and I want to check the value of that flag throughout my application(force.com website). But if I try to access it in another class, the value is coming as null. Can anyone help me with this?
Best Answer chosen by Vetriselvan Manoharan
Nitin PaliwalNitin Paliwal
Hi,
Have you first made the instance of that class(with sharing) in which you have assigned the value of the Public variable in your another class?

Thanks
Nitin

All Answers

Nitin PaliwalNitin Paliwal
Hi,
Have you first made the instance of that class(with sharing) in which you have assigned the value of the Public variable in your another class?

Thanks
Nitin
This was selected as the best answer
SantoshChitalkarSantoshChitalkar
Hi vetriselvan manoharan,

Refer following code sample - 
public with sharing class DeclareVariable{

public static Boolean isValue = false;

public void yourMethod(){

}

}



-------------------------------------------------------------------------
public with sharing class AccessVariable{


public void yourMethod(){
     Boolean checkValue =  DeclareVariable.isValue;
     system.debug('@@@@'+checkValue);
}

}

Hope it help !!!!

Regards,
Santosh Chitalkar
Vetriselvan ManoharanVetriselvan Manoharan
@nitin : you solution worked out. Thanks man..