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

Service Industry Transformation: AI Chatbots and Automation featured image
January 9, 2026
This post examines how AI chatbots are reshaping service-driven industries such as hospitality, healthcare, and retail. These businesses face constant pressure from high conversation volume, limited staff availability, and rising customer expectations. The article explains how chatbots handle repetitive, predictable interactions like bookings, FAQs, and status updates, allowing human teams to focus on in-person service and complex situations. It emphasizes that automation does not remove the human touch but strengthens it by reducing burnout and improving response times. The summary concludes by describing Anablock’s approach to service industry automation, focusing on task completion, system integration, and smooth escalation to human support.
Enhancing Customer Onboarding with AI Chatbots featured image
January 8, 2026
This article focuses on the critical role onboarding plays in retention and long-term customer success. Many users churn early because they feel overwhelmed, confused, or unsupported during their first interactions with a product or service. The post explains how AI chatbots transform onboarding into an interactive, real-time experience by guiding users step by step, answering questions inside the flow of work, and offering help when users stall. It highlights benefits for both users and internal teams, including faster activation, reduced support tickets, and clearer insight into onboarding friction points. The summary also covers how Anablock designs onboarding assistants using real product data to deliver personalized, context-aware guidance.
AI Chatbots vs Human Customer Service: Finding the Perfect Balance featured image
January 7, 2026
This article breaks down the real differences between AI chatbots and human customer service and explains why choosing one over the other is a false choice. AI chatbots excel at handling repetitive, high-volume requests instantly, while human agents bring empathy, judgment, and adaptability to complex situations. The most effective solution is a hybrid support model where automation resolves simple issues and prepares context before handing off to humans. When designed correctly, this approach improves efficiency, shortens response times, and delivers a better customer experience without sacrificing the human touch.

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