**Sorry for all of my annoying posts, it's been crunch time on this project**

I have 9,000+ accounts in SF that I needed to link to Drupal Users in a Drupal site. My strategy has been the following:
1. Created all accounts in SF by uploading a CSV of all 9,000+ records
2. Used the node_import module in my Drupal site to upload all of the records with the following fields, username (a auto-number field from SF used as the accounts member number), password (based on some address data for the user), and SFid. My goal was to just get the least amount of information into my Drupal site since SF was going to be storing the rest. Also, my reason for the SFid was just so that I had it attached to each user just in case I ran in to any problems.
3. Imported a CSV file of my oids and sfids into the salesforce_object_map table to force the connection between the two objects.

I have everything working up to this point, but I'm noticing that the fields aren't pulling in from SF until I click the magic "import changes from Salesforce" button on the Salesforce tab for each user. Is there a better way to do this? I maxed out my API limit yesterday and had to push back my work a whole day (or until they extended my limit for a few days). Anyway, rather than running the import feature I want to check and see if there's a better way to do this. Am I better off just running another import on my Drupal site with the rest of the profile field data? At this point it might be too late for that since the node_import module doesn't allow me to upload field data to existing users. Does the user_import module allow that? Sorry, lots of questions...just want to make sure that I'm doing the right thing here. Thanks in advance for anyone's help.

Comments

amariotti’s picture

I guess my main question is how can I perform the "import changes from Salesforce" button on all of my 9000+ records now that they are linked appropriately?

kostajh’s picture

The approach you are taking seems to work okay but is probably not how I would go about doing this. If it were me I would

  • Create the SF accounts/contacts by uploading the CSV
  • Enable the salesforce_api, sf_user, and sf_import modules
  • Create the fieldmap you want to use at admin/settings/salesforce
  • Test the patch for importing records via Drush #1066070: drush command for importing salesforce content or use the methods provided by the UI of sf_import

As for updating, the objects in Drupal don't automatically update from Salesforce. You have to either implement sf_notifications to use Salesforce Outbound Messages or implement hook_cron in a custom module to poll Salesforce for changes and update the Drupal records based on that. As a side note, implementing a configurable hook_cron might be a good feature to add into sf_import module.

If you are only concerned about one-way synchronization (pulling the latest data from Salesforce and displaying it via Drupal) then you could also take a look at Salesforce Feeds

amariotti’s picture

kostajh,

Thanks for your post, I really appreciate your time and assistance.

So I guess what I need to do at this point is take and import the field data into the Drupal site, and then take a look at the drush integration. Is there an advantage to running it in drush vs. on the Drupal site? I've had some bad experience with the sf_import erroring out after about 20% of the import. Anyway, maybe I'm just not understanding a few things here. I'm just importing the data now and will report back. I'm hoping that I can contribute back to the documentation once I'm done. I think doing what I'm doing has taken a lot of time that a single documentation page would've solved.

Reports coming back soon.

aaronbauman’s picture

cross posting #1135752: Build-out of ongoing imports - polling feature for synchronizing from Salesforce to Drupal

would be a big help to try out the referenced patch using real data sets.

dpearcefl’s picture

If you are maxing out your API limit during an Import, you may want to look at this issue: #1138154: sf_import_batchjob performance improvement

kostajh’s picture

Status: Active » Fixed
amariotti’s picture

Status: Fixed » Active

Can someone interpret this error for me on my watchdog log?

Duplicate entry '' for key 2 query: INSERT INTO users (created) VALUES (1305161082) in /home/muledeer/public_html/modules/user/user.module on line 329.

amariotti’s picture

Here's another confusing one:

muledeer@muledeer.org [~/www]# drush sf-import 25bec3bec36bf0133ec0ace85cad22c1
drush: Error while querying Salesforce : INVALID_FIELD: 
State__c, Zip_Code__c, Geocode__c, Id, Name, Regional_Director__c
                                   ^
ERROR at Row:2:Column:75
duplicate field selected: Id
Drush command terminated abnormally due to an unrecoverable error.                                                                                                             [error]
Error: Directive 'magic_quotes_gpc' is deprecated in PHP 5.3 and greater in Unknown, line 0

The magic_quotes error concerns me a little bit. I'm using the latest dev version of SF Suite, and latest stable version of Drush. My server is running PHP 5.3.

Is this more of a Drush specific error? Maybe I'm posting this in the wrong place.

aaronbauman’s picture

1. Drupal does not support php 5.3
2. The fact that you can't select the same field twice is a constantly irksome feature of SOQL.
However, we're stuck with it.
So, whatever function creates this SOQL query is responsible for ensuring that there are no duplicate fields in the SELECT statement.

amariotti’s picture

@aaronbauman

1. Drupal does not support php 5.3

It says that it is here: http://drupal.org/requirements

PHP 5.3 is not yet supported by Drupal 5.x, but is supported by Drupal 6.14 core and higher (see the release notes for 6.14) and recommended fr Drupal 7.x. Note that some contributed modules may not be compatible with PHP 5.3, and that some PHP 5.3 configurations still show warnings with Drupal 6.14; work is ongoing to resolve the latter in #360605: PHP 5.3 Compatibility.

2. The fact that you can't select the same field twice is a constantly irksome feature of SOQL.
However, we're stuck with it.
So, whatever function creates this SOQL query is responsible for ensuring that there are no duplicate fields in the SELECT statement.

So, my fieldmap I am using is trying to SELECT the same field twice to map? Is that what you're saying?

amariotti’s picture

Here's my fieldmap export:

 $salesforce_field_map = new stdClass;
$salesforce_field_map->disabled = FALSE; /* Edit this to true to make a default salesforce_field_map disabled initially */
$salesforce_field_map->name = '25bec3bec36bf0133ec0ace85cad22c1';
$salesforce_field_map->automatic = 7;
$salesforce_field_map->drupal = 'node_chapter';
$salesforce_field_map->salesforce = 'Chapter__c';
$salesforce_field_map->description = 'Chapter mapping';
$salesforce_field_map->fields = array(
  'Chapter_ID__c' => 'field_chapter_id',
  'City__c' => 'field_chapter_city',
  'State__c' => 'field_chapter_state',
  'Zip_Code__c' => 'field_chapter_zip',
  'Geocode__c' => 'field_chapter_geocoder:openlayers_wkt',
  'Id' => 'field_chapter_sfobjectid',
  'Name' => 'title',
  'Regional_Director__c' => 'field_chapter_rd',
);
amariotti’s picture

My watchdog log is covered with this error still after several weeks. Does anyone have any ideas

Duplicate entry '' for key 2 query: INSERT INTO users (pass, status, init, created) VALUES ('8f46519dafcf6587670ae1cfe5363d9a', 1, '', 1310420373) in /home/homeuser/public_html/modules/user/user.module on line 328.

And here's my huge fieldmap:

$salesforce_field_map = new stdClass;
$salesforce_field_map->disabled = FALSE; /* Edit this to true to make a default salesforce_field_map disabled initially */
$salesforce_field_map->name = 'c4ca4238a0b923820dcc509a6f75849b';
$salesforce_field_map->automatic = 3;
$salesforce_field_map->drupal = 'user';
$salesforce_field_map->salesforce = 'Account';
$salesforce_field_map->description = 'User Account Matching';
$salesforce_field_map->fields = array(
  'Join_Date__c' => 'profile_member_signup_date',
  'Member_Expiration_Date__c' => 'profile_membership_expiration_date',
  'City_Secondary__c' => 'profile_city2',
  'City__c' => 'profile_city',
  'FirstName' => 'profile_firstname',
  'Id' => 'profile_sfid',
  'LastName' => 'profile_lastname',
  'Membership_Number__c' => 'profile_membership_number',
  'Membership_Status__c' => 'profile_memberstatus',
  'Membership_Type__c' => 'profile_type',
  'Old_Membership_No__c' => 'profile_oldmemno',
  'Phone' => 'profile_phone',
  'State_Secondary__c' => 'profile_state2',
  'State__c' => 'profile_state',
  'Street_Secondary__c' => 'profile_address2',
  'Street__c' => 'profile_address',
  'Zip_Secondary__c' => 'profile_zipcode2',
  'Zip__c' => 'profile_zipcode',
);

After digging some more, here's what I get:

user warning: Duplicate entry '' for key 2 query: INSERT INTO users (pass, status, init, created, access) VALUES ('a53ddf4901854f1b84c3763819363ca7', 1, '', 1310421490, 1310421490) in /home/homeuser/public_html/modules/user/user.module on line 328.
A user account could not be imported for creation. A required field for Drupal may be missing.
1

Based on that, is this an issue with the password syncing over?

EvanDonovan’s picture

Title: Next Step.... import field data from SF to Drupal » Various errors on importing SF field data into new Drupal objects (users, nodes)

Note the order on the fields: ('a53ddf4901854f1b84c3763819363ca7', 1, '', 1310421490, 1310421490).

It looks like '' is the only one that is blank - that is the "init" field. I think that you would need to map that; it is the initial email address for the user.

There may not be a fieldmapping available for that though currently, in which case it's a bit of a special case that might have to be covered by sf_user. I'm not sure if anyone else is importing users via Salesforce API, which is probably which this hasn't come up before.

I know it's not the password though, since that is the first field - the lengthy hash generated by user_password() function.

I think #11 is a totally separate issue - not sure what's going on there. I think it's with a Drush script though, not the fieldmap.

And yes, Drupal 6 does support PHP 5.3 now. It didn't back when Aaron wrote originally, I think.

amariotti’s picture

@EvanDonovan,

Thanks for help on the issue queue today. You've been most helpful. I find it hard to believe that no one has ever tried to create Drupal user objects from Salesforce objects, but I guess that could be the case. I would be really surprised though. I've talked to the company that Aaron works for as well as another one and they both have done similar things to what I'm trying to accomplish.

So, it definitely does appear that the issue is with the init field being mapped properly. Hopefully there is a way around this. I believe that I've gotten users to sync over properly before, but they were stuck as being inactive...I wonder if this was why? Very strange things going on here...

amariotti’s picture

Made some progress on this. Your comment about the init value being NULL made me look at my fieldmap again and I hadn't mapped the Username or Email fields. Ugh, what a day/week...and it's only Monday.

So I've mapped those over and users appear to be coming through properly, but am still getting lots of different errors on the log....I'll post some more tomorrow or tonight—headin' to school.

EvanDonovan’s picture

Thanks!

Strictly speaking init was '' (empty) rather than NULL. Sounds like mapping email is working, but with other errors (presumably not blocking the import)....

EvanDonovan’s picture

Status: Active » Postponed (maintainer needs more info)

Are you still experiencing these errors?

nicodv’s picture

Version: 6.x-2.x-dev » 7.x-2.0-alpha3

Hi, did you @amariotti solve all your errors? I'm in the same situation and getting nonstop errors of the type Notice: Undefined offset: 0 in sf_entity_export_field_default()
Warning: strpos() expects parameter 1 to be string, array given in url()
or Warning: substr() expects parameter 1 to be string, array given in url()
...but the most important one: is the classical "Account: bad field names on insert/update call: Name"

In case you became an expert now, can you tell me if what i'm doing is absolutely wrong?: I mapped user:account and user:opportunity, the only coincidental field here is username in drupal (pointing at both account name and opportunity name in sf).

Should i expect nothing to work properly because of this?

Besides, I can't see all the mapped fields in the drupal side of the salesforce tab under any user. I see the data in the sf side, but only one or two on the drupal side.

Any help would be really helpful.

thanks in advance

nico

kostajh’s picture

Status: Postponed (maintainer needs more info) » Closed (won't fix)