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
othmaneothmane 

WS callout from trigger

Hello,

 

Force.com requires that when we call a WS callout method from a trigger we Must use the @future annotation for the WS callout method.

But @future methods are not allowed to have any Object as arguments. I need to pass 'Account' object arg to this method but force.com won't allow me.

is there a woraround or a new  solution for the scenario i described above?

 

thanks

Best Answer chosen by Admin (Salesforce Developers) 
bob_buzzardbob_buzzard

Is this an account that has been stored in the database?  If so, pass the id and use a SOQL call to get the record from the DB.  If not, you'll have to find some way to persist the information as the @future call is in a different transaction.

All Answers

bob_buzzardbob_buzzard

Is this an account that has been stored in the database?  If so, pass the id and use a SOQL call to get the record from the DB.  If not, you'll have to find some way to persist the information as the @future call is in a different transaction.

This was selected as the best answer
othmaneothmane

bob_buzzard wrote:

Is this an account that has been stored in the database?  If so, pass the id and use a SOQL call to get the record from the DB.  If not, you'll have to find some way to persist the information as the @future call is in a different transaction.


Great ,thank you for reminding me about using Account.id to reference the Account in my WS callout method. Yes the Account exists in DB.in WS callout method i'm only doing Account read only operations.

So thanks for this good hint.

othmaneothmane

One question plz: Is Contact.Id  of type Integer or String? or what type is it in apex?

bob_buzzardbob_buzzard

The type is Id - you can also use a String and it will work.

othmaneothmane

bob_buzzard wrote:

The type is Id - you can also use a String and it will work.


Thank you .this works perfectly.