function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Balasubramani DhanapalBalasubramani Dhanapal 

Record Update using Future Annotation method.?

How to update some particular Records using Future annotation method .Since I am a beginner can any one give an example with the details. Thanks in advance.
Best Answer chosen by Balasubramani Dhanapal
James LoghryJames Loghry
If you havent already, read up on the following document first: https://www.salesforce.com/us/developer/docs/apexcode/Content/apex_classes_annotation_future.htm

Using an example from that page, you would then perform the DML inside your future call, like so:
 
@future 
public static void myMethod(Id contactId, String emailToUpdate){
    try{
        Contact c = new Contact(Id=contactId,Email=emailToUpdate);
        update c;
    }catch(DMLException e){
        //Handle DML Exception here
    }
}

 

All Answers

James LoghryJames Loghry
If you havent already, read up on the following document first: https://www.salesforce.com/us/developer/docs/apexcode/Content/apex_classes_annotation_future.htm

Using an example from that page, you would then perform the DML inside your future call, like so:
 
@future 
public static void myMethod(Id contactId, String emailToUpdate){
    try{
        Contact c = new Contact(Id=contactId,Email=emailToUpdate);
        update c;
    }catch(DMLException e){
        //Handle DML Exception here
    }
}

 
This was selected as the best answer
Balasubramani DhanapalBalasubramani Dhanapal
Thanks  
Mr.James Loghry