I have two sales-force org (org 1 and org 2).I am insert a new account in my org 1 now i want that every time a org 1 account created then org 2 will automatically update its account with org 1 data using rest API .

  • 1
    hv u looked into salesforce to salesforce : help.salesforce.com/… Commented Sep 8, 2015 at 12:32
  • yes i want this feature for my two developer org .kindly help me
    – sheetal
    Commented Sep 8, 2015 at 12:33
  • This is called "Salesforce-to-Salesforce" integration. Salesforce provides it.
    – Ashwani
    Commented Sep 8, 2015 at 12:56
  • how can i achieve this ?
    – sheetal
    Commented Sep 8, 2015 at 13:00

2 Answers 2


You can make your own rest api callouts from the account create trigger in org1 to the salesforce standard api of org2. or alternatively you can set up salesforce to salesforce

Salesforce to Salesforce is a Force.com feature that lets you configure two Force.com environments (orgs) so that they share data records in real time.

This Feature will allow you to sync records between the 2 orgs without the need to write additional callouts in apex.

Writing a custom rest api is something I would only do in a scenario where I have additional logic that needs to be executed or when additional abstraction is preferred in the API.


You can build a custom REST API using APEX REST or SOAP API with Apex webservice methods download the WSDL expose it to the other system.

My suggestion is build a REST API using Apex REST with @RestResource

Pls refer to this link below on how to create REST API using Apex and testing it out using postman/Workbench application.


You need to share the URL with external applications to access you API:


They need to send a request to you as {"case_number":"1234"}

Based on this account name posted it will query and send the reponse as JSON.

HTTP Class:

global class RestTestController {
global static void getTestAccount() {

RestRequest req = RestContext.request;
RestResponse res = RestContext.response;
res.addHeader('Content-Type', 'application/json');
String jsonResponse = '';
String CaseNo= req.params.get('case_number');

// No account_name parameter was found; return status 400
if(CaseNo== null) {
    res.statusCode = 400;
    jsonResponse = '{"response": {"status": "Failure", "message": "MissingRequiredQueryParameter case_number"}}';
    res.responseBody = blob.valueOf(jsonResponse);

// Get the list of cases that match the case_number sent in the request.
List<case> cases = [SELECT Id, CaseNumber, Account.Name
                          FROM case
                          WHERE CaseNumber=: CaseNo];

// No accounts with matching case_number
if( cases.isEmpty()) {
    res.statusCode = 400;
    jsonResponse = '{"response": {"status": "Failure", "message": "No case matching case_number was found"}}';
    res.responseBody = blob.valueOf(jsonResponse);

 // At least 1 account was found, JSON serialize it and send it back.
try {
    res.statusCode = 200;
    jsonResponse = Json.serialize(cases[0]);
    res.responseBody = blob.valueOf(jsonResponse);
} catch ( Exception ex ) {
    res.statusCode = 500;
    jsonResponse = '{"response": {"status": "Failure", "message": "' + ex + '"}}';
    res.responseBody = blob.valueOf(jsonResponse);
  • i want this thing using rest api only
    – sheetal
    Commented Sep 9, 2015 at 5:03
  • Do you wanna build a custom REST API using apex and expose it to other org? or Do you wanna make an asynchronous callout using an apex trigger? Commented Sep 9, 2015 at 14:28
  • I wanna build a custom REST API using apex and expose it to other org
    – sheetal
    Commented Sep 10, 2015 at 3:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .