Closed (fixed)
Project:
Salesforce Suite
Version:
7.x-3.x-dev
Component:
salesforce_push.module
Priority:
Normal
Category:
Bug report
Assigned:
Reporter:
Created:
26 Oct 2015 at 16:20 UTC
Updated:
1 Jan 2016 at 06:24 UTC
Jump to comment: Most recent
Comments
Comment #2
aaronbaumanhard to argue with that
Comment #3
gcb@tauno has pointed out that we need to test the behavior with upserts, which I haven't done. Any chance you looked at that Aaron? I suspect it will work fine but flagging it here so it gets looked at before committing.
Comment #4
aaronbaumanI think this patch is a step in the right direction.
The only 100% safe way to do an upsert is to only send values which are both createable and updateable.
We could add error handling to deal with non-createable and non-updateable fields for upserts, but I think those errors will mostly be edge cases. In my own experience, I'm mostly using update-only or create-only fields as pull-only. Do you have different use cases in mind?
When #2186153: Provide additional Salesforce push/pull hooks for pre_export changes. gets in, we'll be able to delegate the edge cases to other contrib.
Comment #5
gcbWell, the upsert functions are different API calls on Salesforce, so my assumption is that Salesforce won't complain about sending non-updateable fields in a case where we are explicitly uncertain if we are doing an insert or an update: we just need to test that assumption. Hopefully that's accurate and all is fine: we also need to make sure that my code hasn't stopped those values from populating in upserts.
Comment #6
aaronbaumanActually I'd guess that SF will complain if you try to update a non-updateable field, even when using upsert, but I can't find anything to test and I can't find any answers in SF documentation.
That said, a createable-but-not-updateable field is an edge case.
There are none on standard objects like Account, Contact, Opportunity, Campaign, Case.
All the non-updateable fields on these objects are also non-createable.
"IsConverted" flag on a Lead is createable-but-not-updateable, but not a useful example because it's tied into SF's core lead-conversion workflow, and heavily locked down.
And, there's no way (at least not through the UI) to create a custom createable-but-not-updateable field.
Comment #7
gcbThe common create-able but not update-able fields that I use regularly are all object references. For both Notes and Campaign Memberships, the parent object reference is non-updateable. The same is true for Campaign Member's Contact reference: these are the use cases this patch was specifically written to handle.
Comment #8
aaronbaumangotcha, i think those are both Master-Detail relationships.
Upsert will complain.
Here's my drush test with CampaignMember and an external foreign key called "TEST_FK__c":
All that said, this bug is already present in this module, and probably merits its own issue.
Comment #10
tauno commentedCommitted in 4f445d3. I'm not sure there's a good way of handling the upsert case. Extending hook_salesforce_push_fail to be called for REST push failures would make it easier to handle the upsert failures.