Scope and Visibility of @RemoteAction Methods

Apex @RemoteAction methods must be static and either global or public.

Don’t use globally exposed remote actions to perform sensitive operations or to expose nonpublic data. Global remote actions can only call other global methods. You can’t use public remote actions in global components, or in a global scope. Scope escalation results in a compiler error, or for references that are resolved at runtime, a runtime failure. This table describes the restrictions.

@RemoteAction ScopeVisualforce PageNon-Global ComponentGlobal ComponentiframeAccess Across Packages
Global Remote MethodAllowedAllowedAllowedAllowedAllowed
Public Remote MethodAllowedAllowedErrorErrorPackages must share the namespace. Method must have the @namespaceAccessible annotation.

If a @RemoteAction method is in a managed package and used by Visualforce Remoting, it must have global visibility if user profile or permission set access is used.

Note

When remote actions are accessed via markup they are included indirectly via components, the <apex:include>, or the <apex:composition> tags. The scope of the remote method is carried forward into the top-level container (the top-level item in the inclusion hierarchy), which must abide by scope escalation rules.

@RemoteAction Accessed FromVisualforce PageNon-Global ComponentGlobal Componentiframe
Global ComponentAllowedAllowedAllowedAllowed
Non-Global ComponentAllowedAllowedAllowed only if non-global component doesn’t include public remote methods.Allowed only if non-global component doesn’t include public remote methods.
<apex:include> <apex:composition>Allowed within the same namespace; error if namespaces are different and the included page or its child hierarchy contains public remote methods.n/an/aError