• gsapp
  • NEWBIE
  • 0 Points
  • Member since 2011

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    Replies

Hi,

 

  I'm having an issue trying to update an account record using a future method.  It is necessary to use the future method because ultimately I want the record to be updated from the result of a webservice method.  From what I understand, callouts are only allowed from future methods.

 

I was following the pattern outlined here.

http://www.cheenath.com/?tutorial/sfdc/sample1/index.html

 

Here Is my code:

 

 

public class setAccount
{
    @future(callout = true)
    public static void setWebsite(String AccountID) 
    {
        //Account a = [SELECT Website from Account where Id =:AccountID];
        Account acc = new Account(Id=AccountID);
        //tempuriOrg.Service1Soap Service = new tempuriOrg.Service1Soap();
        acc.Website = 'http://www.helloworld.com';//Service.HelloWorld();
        update acc;
    }

}

 

trigger CreateTegrityInstances on Account (before update, before insert) 
{
    //setAccount webServiceThing = new setAccount();
    for(Account a : Trigger.new)
    {
        setAccount.setWebsite(a.Id);
        //update a;
    }
}

 

 

 

If I remove the update acc the exception goes away.  

 

Here is the exception:

Update failed. First exception on row 0 with id 001T000000hRmldIAC; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, CreateTegrityInstances: execution of BeforeUpdate caused by: System.AsyncException: Future method cannot be called from a future method

 

 

Any help you can provide is greatly appreciated.

 

Thank you.

  • April 01, 2011
  • Like
  • 0

Hi,

 

  I'm having an issue trying to update an account record using a future method.  It is necessary to use the future method because ultimately I want the record to be updated from the result of a webservice method.  From what I understand, callouts are only allowed from future methods.

 

I was following the pattern outlined here.

http://www.cheenath.com/?tutorial/sfdc/sample1/index.html

 

Here Is my code:

 

 

public class setAccount
{
    @future(callout = true)
    public static void setWebsite(String AccountID) 
    {
        //Account a = [SELECT Website from Account where Id =:AccountID];
        Account acc = new Account(Id=AccountID);
        //tempuriOrg.Service1Soap Service = new tempuriOrg.Service1Soap();
        acc.Website = 'http://www.helloworld.com';//Service.HelloWorld();
        update acc;
    }

}

 

trigger CreateTegrityInstances on Account (before update, before insert) 
{
    //setAccount webServiceThing = new setAccount();
    for(Account a : Trigger.new)
    {
        setAccount.setWebsite(a.Id);
        //update a;
    }
}

 

 

 

If I remove the update acc the exception goes away.  

 

Here is the exception:

Update failed. First exception on row 0 with id 001T000000hRmldIAC; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, CreateTegrityInstances: execution of BeforeUpdate caused by: System.AsyncException: Future method cannot be called from a future method

 

 

Any help you can provide is greatly appreciated.

 

Thank you.

  • April 01, 2011
  • Like
  • 0