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
SalesforceBluesSalesforceBlues 

Reg - Usage of Global Variables in Global Class

Hi,

I have been wondering why the usage of Global variables are different in Global as well as public Classes.

 

Scenario 1 : 

I have declared a Global Variable in public class and passed the varaible to the other methods in the same class or different class as a reference and was able to get the values in my global variable.

 

Scenario 2: 

I have declared a Global Variable in Global class and passed the varaible to the other methods in the same class or different class as a reference and was not able to get the values in my global variable. It was coming as null values most of the times and was working some times.

 

I wonder what should be the difference between those two scenarios. When i make it as Static Global variable it works for me then again that will effect the Functionality if we are calling the classes asynchronoulsy.

 

Is the a salesforce bug

 

Any thoughts...................

 

Thanks

Mohan