You need to sign in to do that
Don't have an account?
GregWax
Call Web Service from Apex Trigger to perform Address Standardization and geo-coding real time
Page: Account
Trigger: before insert, before update
Debug Log:
METHOD_ENTRY|[315]|01pP00000008Yot|Mappable.invokeWebService(System.Http, System.HttpRequest)
METHOD_ENTRY|[170]|System.Http.send(APEX_OBJECT)
EXCEPTION_THROWN|[170]|System.CalloutException: Callout from triggers are currently not supported.
It has been suggested to use @future, however I need real time validation and @future methods are asynchronous.
I appreciate any suggestions
Hi Greg,
Currently call outs are not supported in apex triggers. You may need to invoke an apex class from the trigger and do the call outs in your apex class. Do have a look at this document, Apex CallOuts .
Thanks.
Greg,
As indicated earlier, there is currently no way to make syncronous callouts from a Trigger context. Using the @future notation to make the callout aysnc is really the only option (short of developing a custom VF page for your CRUD use case). Though it would obviously be ideal to perform the address standardization and geo-coding in real-time, what's the exact issue with making them 'real near-time' (i.e within minutes/secs of the update/insert) with a @future callout? Is that that the user won't know if the address they entered was incorrect?
Thank you for confirming the issue about synchronous web calls in trigger
The business requirements specifies that the address be validated while the user is still on the Account page.
If the address is incomplete/wrong then the user has a chance to correct before saving.
The same apec class that I created works for Bulk update and for a mapping button.
Using the web call asynchronously defeats the goal. Once a the user leaves the Account screen they don't take the time to review the record.
Thanks very much for you help.
Instead of using a trigger, Is there a field rule or workflow that could call my apex web service?
Not really. You could setup an Outbound Message via a workflow that calls out to an external web service (but not to an Apex web service) every time an Account record is updated. However that is also async and so won't meet your requirement either. Sorry to be bearer of bad news :(
I have same requirement for Address Standardization on Account object.
Can you please post the sample webservice code and help me how to call that webservice from my application.