+ Start a Discussion
sfdclearnsfdclearn 

Trigger that updates a field in a different SFDC org when a field is changed.

Hi,

 

   Here is the scenario. The opportunity stage in SFDC org1 goes to closed won. Then the opp stage in SFDC org2 should go to closed won as well. Is there a way we can accomplish this with an Apex trigger? If so any one has the sample code for this.

 

Please advise.

 

Thanks!!!

bob_buzzardbob_buzzard

One way you might be able to do this is to make a web services call to the second org.  You'll need to store credentials somewhere and use an @future call or some scheduled apex (as you can't make callouts from a trigger).  

 

Check out this post from my fellow Force.com MVP Abhinav Gupta - its actually around calling a webservice in the same org, but should be adaptable for your situation:

 

http://www.tgerm.com/2010/12/invoking-apex-wsdl-web-services-from.html

boBNunnyboBNunny

You can also use Inbound Messaging.  Send an email to the 2nd org with the required data, and then handle that message with an Inbound Message class.