Salesforce Apex Annotations

Himanshu Varshney
Senior Salesforce Developer
January 19, 2024

HimanshuBlkogpost

@AuraEnabled

Purpose: Makes a method accessible from a Lightning component.

Example:


public class MyController {
    @AuraEnabled
    public static String sayHello(String name) {
        return 'Hello ' + name;
    }
}


@Deprecated

Purpose: Indicates that a method or class should no longer be used.

Example:


public class OldClass {
    @Deprecated
    public static void oldMethod() {
        // Old implementation
    }
}


@Future

Purpose: Marks a method that runs asynchronously.

Example:

public class AsyncProcessor {
    @Future
    public static void processAsync() {
        // Asynchronous processing
    }
}
@InvocableMethod

Purpose: Allows a method to be called from a Process Builder or Flow.
Example:
apex
Copy code
public class FlowController {
    @InvocableMethod
    public static void processRecords(List<Id> recordIds) {
        // Process logic
    }
}


@InvocableVariable

Purpose: Used within a class that has @InvocableMethod to define variables that can be set from a Flow or Process Builder.

Example:

public class Parameters {
    @InvocableVariable
    public String param1;
}


@IsTest

Purpose: Marks a class or method as a test class or test method.

Example:

@IsTest
private class TestMyClass {
    @IsTest static void testMyMethod() {
        // Test code
    }
}


@JsonAccess

Purpose: Allows non-public members of Apex classes to be serialized and deserialized in JSON.

Example:


public class MyClass {
    @JsonAccess
    private String myField;
}


@NamespaceAccessible

Purpose: Exposes a global class, method, or variable to any Apex code that resides in a namespace.

Example:

@NamespaceAccessible
public class SharedClass {
    // Class implementation
}


@ReadOnly

Purpose: Allows a Visualforce page to perform read-only operations that do not count against the governor limits for SOQL queries.

Example:

@ReadOnly
public with sharing class MyReadOnlyClass {
    // Query logic
}


@RemoteAction

Purpose: Exposes a method in a Visualforce controller to be called from JavaScript.

Example:


public with sharing class MyController {
    @RemoteAction
    public static String performAction(String param) {
        // Action logic
    }
}


@SuppressWarnings

Purpose: Instructs the compiler to suppress specific warnings.

Example:


@SuppressWarnings('deprecation')
public class MySuppressedClass {
    // Code that uses deprecated methods
}


@TestSetup

Purpose: Used in test classes to define methods that set up test data.

Example:


@IsTest
private class MyTestClass {
    @TestSetup
    static void setup() {
        // Setup test data
    }
}


@TestVisible

Purpose: Allows test methods to access private or protected members of another class.

Example:

public class MyClass {
    @TestVisible private static Integer myCounter = 0;
}

Each of these annotations serves a specific purpose and helps define the behavior of your Apex code in different scenarios, particularly in the context of Salesforce's multi-tenant environment and its governor limits.

Share this article:
View all articles

Related Articles

How AI Automation Finds Upsell and Cross-Sell Opportunities in Your CRM featured image
January 15, 2026
Most CRMs contain far more revenue potential than teams are able to unlock manually. Usage data, support history, renewal timing, and engagement signals all point toward upsell and cross-sell opportunities, but identifying those patterns consistently is nearly impossible at scale without automation. AI changes that by continuously analyzing CRM and connected system data to surface actionable revenue insights. Instead of relying on intuition or sporadic reports, AI models identify patterns that historically lead to successful expansions and apply them across the entire customer base. These AI recommendations help sales, customer success, and marketing teams align around the right accounts at the right time with offers that feel relevant rather than pushy. Over time, the system learns from outcomes and improves its accuracy, turning the CRM into a proactive revenue engine rather than a passive database.
When You Need More Than Zapier: Custom AI Solutions for Complex Integrations featured image
January 14, 2026
No-code integration tools like Zapier work well for simple automations, but they quickly reach their limits as businesses grow. When workflows require complex logic, multiple systems, advanced error handling, and data enrichment, generic tools become fragile and difficult to maintain. This is where custom AI integrations become essential. Custom integration layers powered by AI allow businesses to orchestrate APIs intelligently, apply business rules dynamically, and reason over data instead of simply passing it between systems. By centralizing automation logic, companies avoid the spaghetti mess of point-to-point connections and gain better visibility, reliability, and control. AI adds an additional layer of intelligence by classifying events, detecting anomalies, and choosing the correct workflow paths. For organizations where data accuracy and operational reliability directly impact revenue, moving beyond Zapier is not an upgrade. It is a requirement for sustainable growth.
Meet Your AI Salesforce Admin: Automating Everyday Configuration Tasks featured image
January 13, 2026
Salesforce administrators spend a large portion of their time handling repetitive configuration requests that slow down the entire organization. From creating fields and updating page layouts to fixing broken automations and adjusting validation rules, these small tasks pile up quickly and reduce overall productivity. An AI Salesforce Admin changes how this work gets done by automating everyday configuration tasks safely and consistently. Instead of submitting tickets and waiting days for updates, teams can describe their needs in natural language while the AI agent interprets the request, applies governance rules, and executes or prepares changes for approval. With built-in guardrails, audit trails, and permission controls, automation does not mean loss of control. It means faster changes, cleaner data, and more time for human admins to focus on architecture, scalability, and long-term CRM strategy. The result is a Salesforce environment that keeps pace with business growth rather than holding it back.

Unlock the Full Power of AI-Driven Transformation

Schedule Demo

See how Anablock can automate and scale your business with AI.

Book Demo

Start a Support Agent

Talk directly with our AI experts and get real-time guidance.

Call Now

Send us a Message

Summarize this page content with AI