Closed (fixed)
Project:
Salesforce Suite
Version:
8.x-3.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
10 May 2013 at 21:38 UTC
Updated:
6 Jan 2017 at 17:45 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
markhuot commentedAttaching a patch of how I fixed the issue.
Comment #2
kostajh commentedComment #3
kostajh commentedThanks for the patch. I think it would be better to check
$contactbefore assigning the SFID, though.Comment #4
mariacha1 commentedHere's a new version of the patch with a couple notes:
We're not making the second call out unless the
$data['id']comes back empty the first time around.Also not setting
$data['id']unless$contact['id']is set.Finally, if all that happens and there's still no
$data['id']throw a message to keep the record from being inserted into the database with an empty id. (If that happens more than once it throws a nasty PDO error.)Comment #5
moss.dev commentedHi, I have just been testing this patch,
I found that $conatact['id'] needs to be changed to $conatact['Id'] - uppercase I in Id, then all works well.
Thanks, for the patch.
Comment #6
kostajh commentedComment #7
aaronbaumanCouple more minor necessary for this patch:
Finally, minor point of clarification: the initial assertion is not quite accurate.
A SFID will be returned from an upsert() call if an object was created.
This is an important feature that will limit unnecessary API calls.
Comment #8
moss.dev commentedI now have content in sync after this patch.
But... one issue I am still getting here is, the Salesforce ID (even on node creation) is not populated to the node. I am having to use a Node ID (External ID) field on salesforce records to check for duplication.
When the node is created and salesforce_push does its stuff the Salesforce ID is sent back but the module is not picking it up. It is shown in the status message but does not make it back to the content.
I'm sure before this patch the Salesforce ID was populated on creation (I may be totally mistaken here) but it definitely happened at one point as I have populated fields.
I will try and get this side of it working today and report back if I manage to.
Comment #9
aaronbaumanWhen Drupal has a record of the Salesforce ID, it is in db table
salesforce_mapping_object, and is assigned to$entity->salesforce_idduringsalesforce_mapping_entity_load()If salesforce_id property is empty or not set, it's because there is no db record of a salesforce object (and your sync probably failed, or was never triggered).
The only explanation I can see for what you're experiencing -- the SF ID reported in the status message but not saved to the db -- is that for some reason the call
$mapped_objects->save();at the end ofsalesforce_push_sync_restis failing. If that's the case, there will be PHP or watchdog error log messages about it.Comment #10
moss.dev commentedOh no, sorry maybe I am not explaining myself to well.
The object sync'd correctly, I have the salesforce ID in
salesforce_mapping_object, everything is working as it should.I also have a field mapped in drupal to the Salesforce ID, which in the old salesforce suite I would use as a key to check the items matched and the record already existed.
I have added this mapping with the new salesforce suite so when I save a node in drupal it pushes all of the fields to Salesforce and what I am then expecting is Salesforce to return the Salesforce ID and that to get updated on the field on the node.
At some point with the new module this has happened as I have some content with the correct SFID stored in my field on the node. At some point this has stopped happening and that was what originally brought me to this thread. It may be that the two are totaly unrelated and I am also starting to think that due to the API update this isn't really supposed to happen any more (although it seems very strange to me that the SFID is not being used as a key now).
Comment #11
aaronbaumanOK, here is the key difference:
This issue thread is not about field mappings.
You should create a new issue with your concern (if there isn't one already).
Comment #12
aaronbaumanAnother point on the original issue:
This is actually a more fundamental problem with our Drupal schema in that we rely on Salesforce Id so pervasively.
If we're using upsert(), we already have a unique foreign identifier for the record.
Technically we don't need to store the salesforce id on the Drupal side at all.
(Arguably it's nice to have, but as demonstrated in this issue it can actually cause more confusion.)
I'm not saying it's strictly necessary to fix this issue, but a systemic fix would allow the value of "salesforce_id" to accommodate whatever identifier is used to synch the record -- Salesforce Id, Foreign Key, or LookupId.
Comment #13
bleedev commentedThis is now being handled as of commit 2575031.
Comment #14
aaronbaumanComment #17
aaronbaumanCross-promotion: please go upvote this idea
https://success.salesforce.com/ideaView?id=08730000000aBr9AAE
Comment #19
aaronbaumanThis is committed.
Please still go and up-vote this idea though:
https://success.salesforce.com/ideaView?id=08730000000aBr9AAE
It would be nice to not have to do this.