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
NareshNaresh 

How to call a Web Service from a Trigger or Visual Force page

Hi,
My Requirement:
                                When a user create/edit the Contact object the email address (Email field on Contact) should be verified through a external web service. If the email address is  not valid user do not allow to create/edit the Contact.

Implemented Solution 1:
                                   
I have created a trigger on the Contact Object that calls an Apex class. That class then calls another Web Service. But it gives the error like this: "Callout from triggers are currently not supported". So could not able to achieve the solution.

Implemented Solution 2:
                                  After getting the error by using Trigger i tried to call the Web service through Visual force page. I have to call the web service when user create/edit the Contact. And I need to display the same standard edit (edit mode)page layout of Contact. I am not creating any custom page (UI). I need to call the external web service when user click on the 'Save' button on Contact.

Can anyone help me out? Please let me know if anyone want more clarification on this.

Thanks in Advance,
NG

Ron HessRon Hess
Sorry, there is no way to capture the save action on a standard edit page, you must create an edit page in Visualforce, then you can hook or control the process that occurs after the save action is called.

as you found, you cannot callout from a trigger, so the Visualforce method is the only avenue at this time.

There is a @future feature in apex code that is in developer preview, this may allow a callout , but will still occur after the save.       
NareshNaresh
Thanks Ron,
NareshNaresh
Hi Ron,
Thanks for the quick reply. Any other solution on the above requirement? I need to display the standard edit page for Contact so that when user changes the Contact Page layout the edit page in synch.

Thanks again...
NG
jwetzlerjwetzler
Unfortunately, there is not currently an edit component similar to detail, but it is on the roadmap.