Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

Is it possible to connect Salesforce to Salesforce in Apex. I want to bring sample records from Full Copy sandbox to config sandbox and I need to do this as I refresh config sandbox.

I think if we can connect to another sandbox via apex we can automate the process of manual data load.

share|improve this question
    
This should work with salesforce to salesforce. I've set up a connection between two sandbox orgs for the same client. Unfortunately salesforce to salesforce can't go from a production org to a salesforce org. –  Ralph Nov 6 '12 at 3:03
add comment

6 Answers

up vote 3 down vote accepted

This cookbook article, Calling Salesforce Web Services Using Apex shows how to import the Partner API into Apex. You can then call the query and insert operations on that service to communicate with another org. Let me know if this is something you want to explore, I've been having some success with getting the SF SOAP API's working from Apex recently! ;-)

SOAP API Developer's Guide

share|improve this answer
add comment

I reckon Salesforce 2 Salesforce cannot be enabled for two orgs within the same salesforce organisation (I.e. two sandboxes under the same production org) It can only be enabled across two different (partner) orgs, I believe even across two Developer orgs would work.

Besides, a full copy sandbox and a config sandbox will have significant differences in data storage limit.

I've seen a tool like Monarch from Dreamfactory used to seamlessly move data between sandboxes.

http://www.dreamfactory.com/solutions/monarch

The other alternative will be using the Apex DataLoader to move and externalId fields to join up records.

share|improve this answer
1  
This isn't the case. I've setup s2s from one sandbox to another sandbox that both have the same production org. The only limitation appears to be you can only go from a sandbox to another sandbox, and a production/dev org to another production/dev org. –  Ralph Nov 6 '12 at 3:05
add comment

The only way to access your data in that way would be to expose it via the SOAP API.

However, you cannot connect to these APIs from APEX.

Since the data doesn't come into your config only sandbox it is kind of an issue for getting data in there. Your also limited on data size to 500mb in config-only orgs.

You might consider:

  • Outside program that has access to both orgs
  • The SFDC data-loader

Update

Perhaps check out: APEX-Metadata API seems promising for your needs. I guess I assumed the external APIs were black-listed from internal domain requests. This apparently is not the case.

share|improve this answer
    
Thanks for the mention jodran! I believe what he needs is the Partner API, but yes the work I've been doing on the Metadata API and the link to the Cookbook in my answer suggests it is indeed possible, interesting possibilities! :) –  Andrew Fawcett Oct 25 '12 at 1:12
add comment

This sounds like a great use of Salesforce to Salesforce if you don't mind doing all the config to setup the connection. Salesforce to Salesforce only lets you connect sandbox orgs to other sandbox orgs, and production/dev orgs to other production/dev orgs, but there is no limitation for connecting two sandboxes related to the same production org to each other.

Once the config is setup you can use the PartnerNetworkRecordConnection object to automate the sharing.

Let us know how this works out for you!

share|improve this answer
add comment

If all you want is to move data for testing purposes, there is no need for apex. You can do this using Talend (free), Boomi or Informatica Data Loader.

share|improve this answer
add comment

I would take a look here for some direction: http://th3silverlining.com/2010/03/28/salesforce-integration-using-wsdls/

You can expose apex classes/methods that will let you query for the data in an SF system via SOAP or Rest - but you will need to handle the authentication (the article above discusses that at length).

The other challenge you have when moving between systems is re-creating the relationships in the target system e.g. associating Contacts with Accounts, since the AccountIds will be different in the target system. So when you create the new contacts, you need to find their parent accounts, and link them to the new AccountId of their parent account. The easiest way in my experience is to create an external Id field called LiveId, populate that field with the Id from the live system, and then use native upsert to correctly associate the child records with their parent in the new system.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.