RemoteAction Annotation

RemoteAction Annotation In Apex | Salesforce Apex Developer Guide


An Apex annotation, like a Java annotation, modifies how a method or class is used. Annotations begin with a @ symbol and are followed by the appropriate keyword. To add an annotation to a method, specify annotation just before the method or class declaration. For example:

Public class Myclass {
    Public method A () {
        //Apex code logic

In this blog, we are going to discuss @RemoteAction Annotation.

dont miss out iconDon't forget to check out: Crash Course on Apex Triggers Salesforce | Complete Guide with Real Time Scenarios

RemoteAction Annotation:

The Remote Action annotation allows Apex methods in Visualforce to be called via JavaScript. This is commonly referred to as JavaScript remoting. The remote action function in Salesforce allows the user to access any method from any class via JavaScript methods, and the result is returned as a JavaScript object for further manipulation.

Syntax- Add @RemoteAction before defining the method

Public Method A () {
    //Apex Code Logic

Note - The method should also be Global or Public and Static.

Example of Remote Action Annotation:

APEX Class ->

Public Class MyClass {
    List<Account> AccList {get;set;}
    Public static List<Account> getList() {
        AccList = [Select Id, Name, phone from Account];
        return AccList;

dont miss out iconCheck out another amazing blog by Parvez here: Integration of Salesforce with Google Calendar Using REST API

VF Page ->

<apex:page controller = “MyClass”> 
<apex:includeScript value="" />
<script type="text/javascript"> 
function demotask() { 
    function (result, event) { 
        //Code Logic
    }, {escape: true});
<!-- Here You can Print your Acclist List content which is now stored in Result parameter of demotask JS function --->


Popular Salesforce Blogs