I created a fieldmap between the Drupal User account and a Salesforce Contact.

If I create an account in Drupal, a corresponding Contact in Salesforce is not created. I have to view the user, click edit, go to the Salesforce tab, then click Export user. If I do that, then the User account is linked with Salesforce contact and everything works great (edits made in Drupal get pushed to Salesforce, and vice versa).

I need to be able to have any user account created in Drupal automatically mirrored in Salesforce. It seems like the "Automatically create and link new salesforce objects when Drupal objects are created?" option would allow for this. Does anyone have ideas about what to do?

Comments

kostajh’s picture

Category: support » bug

Update:

I created a new fieldmap with a newly created content type (SF Contact), and a Salesforce Contact. I checked the "automatically populate" box. Upon creating a new SF Contact node, a corresponding record was created in Salesforce.

I think there is a problem in that when you delete a fieldmap, a record exists in the Drupal database of whether it should automatically populate Salesforce or not. I think this is the case because I had earlier created a fieldmap between the Drupal User and Salesforce Contact objects *without* the auto populate box checked; deleted this fieldmap; then re-created it with that box checked. When I first created the fieldmap it was assigned the ID 5, and upon recreating it, it was fieldmap 5 again.

2nd update:

If I create a new fieldmap for User->Contact while an existing one is already in place (in this case, fieldmap/5) then I get a new fieldmap ID of 16. I then deleted fieldmap 5 and tried creating a new user. No luck, a corresponding record in Salesforce is not created when adding a new Drupal user account.

TimAlsop’s picture

I am having exact same problem. I first created a fieldmap for user->contact and didn't select the automatic option, then I deleted this fieldmap and created a new one with the automatic option selected. The automatic creation of contacts is not working and I cannot find a way to make it work. My guess is that if I had created my first fieldmap wth automatic option then user->contact updates would be automatic. Do I need to uninstall the module and install it again and then create a new fieldmap with automatic enabled ?

Anonymous’s picture

The the cache for the objects set when the fieldmap is created. I can think of a number of ways to deal with this, each has it's positives and negatives:

1) Clear the cache when you delete any fieldmap
2) Make the cache temporary (with a specific configurable length of time?)
3) Have a "clear sf cache" option?

Suggestions?

aaronbauman’s picture

Status: Active » Needs review
StatusFileSize
new2.43 KB

As far as I can tell, this is only an issue for "user" fieldmaps (as opposed to "node").
I really thought there was a patch in for this already, but I couldn't track it down.

I don't know if someone had a reason to *not* include insert and update operations in sf_user_user, but for whatever reason there were none. Therefore sf_user module simply ignored user_save operations (!!!). Perhaps most people are using "node" fieldmaps and didn't notice?

This patch adds insert, update, and delete operations to hook_user in sf_user.module (sf_user_user), as well as a "skip" flag so that an import won't trigger an export.

TimAlsop’s picture

yes, you are right - the automatic sync is working with nodes, so this is specific to user fieldmaps. I will test your patch and provide more feedback tomorrow.

TimAlsop’s picture

I applied the patch, and then deleted the existing user->contact fieldmap, added a new user->contact fieldmap which has automatic option selected (not sure why there is no option to edit a fieldmap and turn on/off the automatic flag). Then I edited a user which already existed by changing the email address. The user was not copied to salesforce. I then used the export button to copy it to salesforce, and then I edited the user again (changing last name) and this time the updated user was copied to salesforce.

Why did I have to export the user before the automatic sync works ?

aaronbauman’s picture

StatusFileSize
new4.04 KB

2 things

  1. #536292: Automatic syncing can not be changed after fieldmap-creation
  2. Existing users fall into a chicken and egg situation - if automatic sync is on, then a user shouldn't exist without a link to salesforce.
    In other words, the Contact should have been upserted when it was created.
    Since this user already exists in drupal, but the Contact has *not* been upserted to salesforce, it's in limbo.
    The same thing happens for sf_node. See #536298: Allow syncing on update and create.

I updated this patch to address the limbo situation for sf_user and sf_node by combining the insert and update operations of hook_user and hook_nodeapi respectively.

TimAlsop’s picture

So, with this new patch applied, what happens ? If the user/node already exists and has been updated, does the module upsert to salesforce regardless of whether it has already been upserted (e.g. on initial creation) ? If so, I think this is a good patch.

aaronbauman’s picture

Patch #7:
If "automatically populate salesforce" is checked, always upsert user/node on insert/update.

aaronbauman’s picture

Status: Needs review » Closed (duplicate)
aaronbauman’s picture

Status: Closed (duplicate) » Fixed

http://drupal.org/cvs?commit=331012

#536298 is still relevant

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.