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
Niki_16Niki_16 

Updating our own database when salesforce data is updated.

We have an application that is integrated with the salesforce using the custom tab. We want to synchronize our data with the salesforce data (user info). What we actually want is to update our database when any user info is updated from salesforce. Is there any way to achieve such functionality?

 

Thanks,

Shaveta

SuperfellSuperfell
You can use the Workflow Outbound Messaging feature, or write an apex trigger and use @future and callouts to send data to your external system.
Niki_16Niki_16

Can you please provide us an example code.

 

Thanks

Niki

Niki_16Niki_16

What I want is when a username is updated, i need to update that name in my database.

 

Here are the steps i followed: 

1) I have created a web service in .net and then that webservice has been imported in the apex.

2) Then I created a trigger which invokes the web method from that web service.

3) I have also added the remote settings in my account.

 

But still I am getting following error, when a username is updated in salesforce:

 
Error: Invalid Data.
Review all error messages below to correct your data.
Apex trigger NML.UpdateUserName caused an unexpected exception, contact your administrator: NML.UpdateUserName: execution of AfterUpdate caused by: System.CalloutException: Callout from triggers are currently not supported.: Class.NML.ApexCall.ApexCallOutSoap.UpdateUserName: line 21, column 13
 
 
Is there any probelm in the sequence I followed? Or is there any other settings required for calling the callouts?
 
Kindly help!
 
Thanks
Shaveta
SuperfellSuperfell
As the error indicates, you can't do a synchronous callout from within an apex trigger context. You'll need to do the callout asynchronously using the @future feature (see the apex docs)