
There should be configuration options to easily change your SFDC instance url eg: https://*.salesforce.com. Often times organizations have a few sandbox/development SFDC environments as well as their production environments.
These changes are in the patch.
Comments
Comment #1
epicflux CreditAttribution: epicflux commentedI also needed to connect a sandbox account. Different from the above patch I setup the field as a checkbox to flag if the account is a sandbox account. It might make more sense as a textfield if there are development URLs for salesforce other than https://test.salesforce.com.
Comment #2
rickyoh CreditAttribution: rickyoh commentedI'm thinking this is more of an issue with the Salesforce apis and dev urls, but the returned urls you get from api calls from dev sandboxes don't always work, however the specified environment url would always work. Eg: the sfdc api returns https://cs*-api.salesforce.com, which fails on subsequent api calls while cs*.salesforce.com works. I think the only place this module uses that is in Salesforce::setIdentity
I haven't noticed any api URL wackiness on production environments when using https://login.salesforce.com,
Comment #3
haza@rickyoh : you have some coding standard fails in your patch.<
Plus :
I'm not sure to understand that point.
@epicflux : Shouldn't we also change the salesforce_get_api() function ?
I'm also had a look on this issue and also make a patch for that. I'll drop it here. Let's discuss what's the better approach for that !
Comment #4
kostajh CreditAttribution: kostajh commentedThanks for creating this issue and for the work on the patch.
A few thoughts on this:
I would like to see all of this done before this functionality is committed. The current scope of the patch, while helpful, will cause a lot of confusion and problems for many users who think that they will be able to easily switch back and forth between Sandbox and Production.
What do you all think?
Comment #5
levelos CreditAttribution: levelos commented@kostajh, I think that's an ambitious set of goals and it would add a lot complexity to both the code base and interface. In particular, I wonder about ramifications of having a single Drupal entity mapped to multiple SF instances, E.g., it could lead to inadvertent data corruption by sandbox data making it's way into production via the Drupal entity.
IMO, It seems reasonable to force a Drupal instance to a use a given Salesforce instance. Sandbox would be used when developing or testing sites, switching to production when a site's deployed.
Comment #6
kostajh CreditAttribution: kostajh commentedI agree; it would be challenging to to implement well so as to avoid the problems you're describing.
With the patch as it stands, here is the problem I see users running into:
Comment #7
stella CreditAttribution: stella commented@kostajh I'm not as familiar with SF as you are. Could you elaborate on points 3 and 4 in your last comment for me? Is this only an issue if MyCustomField__c on the production SF doesn't match a field in the sandbox SF? Or is it something else.
I had envisaged that the developer would do steps 1 and 2 above, but may also update the salesforce_instance_url and salesforce_refresh_token if necessary - either by re-authorizing it or having the already known values set in settings.php.
Comment #8
kostajh CreditAttribution: kostajh commentedHi @stella,
When you create a link between a Drupal entity and a Salesforce object, that relationship is stored in a Salesforce Mapping Object entity. So in production, you might have a mapping between node/15 and Salesforce ID (SFID) a1X30000000HkonEAC. But once you use a Salesforce sandbox, the SFIDs change - the same Salesforce object might have an ID of b3y40000000HkonDVS. When you go to test out syncing with the Drupal staging and Salesforce sandbox environments, you'll get errors that the Salesforce record ID is invalid.
What's needed is a way to specify multiple Salesforce IDs for a given Salesforce Object Mapping and link these to different Salesforce environments (sandbox1, production, sandbox2, etc), or, as a simpler alternative, you could delete all of your Salesforce Mapping Object entities in the staging environment. But we'd need to expose that functionality to developers via the admin page or drush, because at the moment you have to run a SQL query to do that.
If in the Salesforce sandbox you've changed the type of a field, or adjusted the field name, or removed fields, then syncing between Drupal and Salesforce will fail.
Probably the best way to handle that situation would be, after switching Salesforce environments in the admin page, running an automated review of the fieldmaps and letting the admin know which fields in the field mapping have changed and need to be adjusted.
Comment #9
epicflux CreditAttribution: epicflux commentedI realize the thread has gone on to discuss higher level issues then my original patch addressed, but for folks that may need it I re-rolled that patch.
Comment #10
kostajh CreditAttribution: kostajh commentedOk, my concerns with this aside, it is a useful patch and could be committed, with follow-up tasks to deal with some of the other issues mentioned here. Thanks to all who have worked on it.
I reworked the patch to add a few words of warning for those who will be using this configuration setting.
Comment #11
tsphethean CreditAttribution: tsphethean commentedDoesn't this patch have the downside that we're still hardcoding (twice) the endpoint of the Salesforce environment? Not all sandboxes end up at test.salesforce.com, so rather than having a boolean "I'm using a test environment", why not a variable which simply defines the URL of the Salesforce environment to login to?
Comment #12
tsphethean CreditAttribution: tsphethean commentedHere is a tweak to the patch to reflect my comment in #11 - I had to do this to get the module to work with a cs18.salesforce.com sandbox.
In terms of a concern about switching from test to production, the dev would have to be cloning the sandbox to production in any case, in which case the links would be maintained, but the workflow I see more likely is both Drupal and Salesforce dev sites being built side by side with test data, using the endpoint configured to point to the test sandbox, and then when "finished", the configuration for both would be pushed to live which would then use a production Salesforce instance and have different objects in any case.
Comment #13
EvanDonovan CreditAttribution: EvanDonovan commentedI think a simple patch that addresses the issue of the endpoint with a global variable - "test.salesforce.com" vs. "login.salesforce.com", etc. would meet the needs of most people without adding substantial complexity to the module. That is how I am reading #11 as well.
In light of that, I think that #12 is the direction to go, although I have not tested the patch yet.
Comment #14
nonsieThere's also the case of multiple production and corresponding dev instances but that would require a major rewrite to accomplish it:(
Comment #15
fabianx CreditAttribution: fabianx commentedThere is a bug in the #12 patch, providing a new patch now.
Comment #16
fabianx CreditAttribution: fabianx commentedI would RTBC this as it works great for my purposes, but I had to fix #12, which had a typo in it.
So lets call this a:
RTBC + 1
Someone else will need to do the actual RTBC.
Interdiff:
The interdiff is trivial though. I am using this in combination with Pantheons environments and it works like a charm!
Comment #17
tsphethean CreditAttribution: tsphethean commented@Fabianx - Thanks for catching my typo
Not sure if I should really RTBC a patch to my own initial patch but your fix works on my sandbox so here goes...
Comment #18
kostajh CreditAttribution: kostajh commentedThis is committed in 2f2d18e8912d51df. I made a few small changes to the wording under "Advanced". Thanks to everyone who contributed to this issue!