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
jojoforcejojoforce 

Accessing a global variable in a RemoteAction method? Error: Compile Error: Variable does not exist

Hi,

I have the following apex class, and if I try to compile I get the following error message.

Error: Compile Error: Variable does not exis

How do I access a global variable in a global remoteable method?
 
global class MyGlobalClass {

  global string test1 = 'mystring';

  @RemoteAction
  global static string returnStringMethod() {
      return test1;
  }
  
}

 
Prady01Prady01
try this! thanks
 
global class MyGlobalClass {

  global static string test1 = 'mystring';

  @RemoteAction
  global static string returnStringMethod() {
      return test1;
  }
  
}

Prady
Hope this helps!