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

Creating Omnichannel Customer Support with AI Chatbots featured image
January 23, 2026
Customers move between channels constantly, and siloed support forces them to repeat themselves. This post explains the difference between multichannel and omnichannel, and how AI chatbots create continuity by identifying users, capturing context, and routing requests consistently across web chat, messaging apps, and other entry points. It also covers why consistency matters, including standardized answers and unified logging into your CRM or helpdesk. Finally, it shows how Anablock approaches omnichannel support by designing the full system, not just installing another widget.
Automating Support Ticket Triage with AI and CRM Integrations featured image
January 22, 2026
Support teams waste massive time on manual triage, reading, tagging, and routing tickets before real problem-solving even begins. This post explains how AI-powered ticket triage can instantly understand ticket intent, urgency, and category, then route each case to the right queue using your existing helpdesk rules. The biggest gains come when triage connects to CRM data, letting the system prioritize based on customer value, plan tier, active opportunities, or recent escalations, not just the words in the message. You’ll also see how this improves agent productivity, reduces transfers, and speeds up first responses. Finally, it outlines Anablock’s implementation approach, using secure API integrations, your real taxonomy and SLAs, and a gradual rollout that builds confidence from auto-tagging to full automation.
Improving Healthcare Appointment Scheduling with AI Chatbots featured image
January 21, 2026
Healthcare scheduling often breaks under phone volume, after-hours demand, and constant reschedules. This post explains how an AI healthcare chatbot can handle booking flows 24/7, collect the right patient details, and offer time slots that follow real clinic rules. It also covers automated reminders that cut no-shows, plus extra patient support like prep instructions and intake guidance. Finally, it explains how Anablock designs healthcare bots around real operational constraints and data protection so clinics get efficiency without sacrificing patient experience.

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