Skip to Content, PHP, MySQL, Javascript, Ajax, Htacces

What are the Apex Annotations available in salesforce, describe about them?

Be First!
by January 25, 2013 APEX, SALESFORCE

Annotations are defined with an initial @ symbol, followed by the appropriate keyword. To add an annotation to a method, specify it immediately before the method or class definition.

Apex supports the following annotations:

S.No Apex Annotation Name Description Example
1 @isTest Defines classes that only

contain code used for

testing your application.

These classes don’t count

against the total amount

of Apex used by your


@isTest private class MyTest {

// Methods for testing


2 @isTest(


Defines a test class or test

method that executes on

package installation


private class TestClass



3 @isTest(


Defines a test class or test

method that has access to

all data in the organization

including pre-existing data

that the test didn’t create.

The default is false.


private class TestClass



4 @deprecated Identifies methods,

classes, exceptions,

enums, interfaces, or

variables that can no

longer be referenced in

subsequent releases of

the managed package in

which they reside



public void limitedShelfLife()



5 @readOnly Defines methods that

can perform queries

unrestricted by the number

of returned rows limit for a




private void doQuery()



6 @remoteAction



Defines Apex controller

methods that JavaScript

code can call from a

Visualforce page via

JavaScript remoting. The

method must be static and

either public or global.


global static String getId(

String s)



7 @restResource Identifies a class that

is available as a REST

resource. The class must

be global. The urlMapping

parameter is your

resource’s name and is

relative to https://instance.





global with sharing class




8 @httpGet,






Defines a REST method

in a class annotated with

@restResource that

the runtime invokes when

a client sends an HTTP




The methods defined with

any of these annotations

must be global and static.



global static MyWidget__c doGet()




global static void doPost()




global static void doDelete()



9 @future Identifies methods

that are executed



global class MyFutureClass {


static void myMethod(

String a, Integer i) {


‘Method called with: ‘ + a +

‘ and ‘ + i);

// do callout, other long

// running code





Leave a Reply