Missing Fields on Automatic Population

Project:Ubercart Contributions
Component:Code
Category:task
Priority:normal
Assigned:bibeksahu
Status:active
Description
Project: 
uc_salesforce

Let me just start by saying thank you for getting this module out there - it is very exciting for us to be able to integrate Ubercart with Salesforce! I'm also not sure if what I'm reporting is a bug report or just a support question.

It looks like on my system, there is no data to automatically populate Salesforce when a user buys something. However, the manual export from the order page seems to be working fine. I am in a test environment, and am using the billing fields only (no delivery fields are active in my setup), so, I'm mapping the field Last Name in the Salesforce Contact object to the field Billing Last Name in Ubercart order. When I go through the checkout process, it tries to do the Salesforce export while I am reviewing the order (earlier than I would expect), and gives me the following error:

stdClass Object
(
    [errors] => stdClass Object
        (
            [fields] => LastName
            [message] => Required fields are missing: [LastName]
            [statusCode] => REQUIRED_FIELD_MISSING
        )

    [id] =>
    [success] =>
)

When I map the Last Name field to the primary e-mail field in ubercart order, it works during checkout, but it creates the Salesforce contact during the order review - which is earlier than I would expect - but maybe intended behavior? It just seems like the billing field data isn't available to the module at this point. I have not yet tried it with mappings to delivery address fields to see if this is similar.

I am using "Other" as the payment method for testing, and have disabled the delivery addresses, I'm only using the billing addresses since we are using Ubercart for event sign up and don't actually have shippable products.

Does this sound like something in my configuration that won't work with the module? Or a bug?

bibeksahu's picture
Offline
Joined: 06/09/2009
Juice: 75
Re: Missing Fields on Automatic Population

Hello,

Sorry for the late response.

Most (but not all) of the problems you mentioned have been addressed in the attached "uc_salesforce.zip" module, if used with either "uc_profile.zip" (attached), or a collection of location-related modules (see below).

"uc_profile" is not intended to become public anytime soon, if ever. In Drupal 7, CCK fields are available for user accounts as well as nodes, and the salesforce module already supports (basic) CCK fields, so the lifespan of a module like this is very short. But you're welcome to it.

Longer-term, we're working on a combination of "uc_location" (http://www.ubercart.org/contrib/13195), "location_first_last_org" (http://www.ubercart.org/contrib/13344), "user_primary_location" (http://www.ubercart.org/contrib/13343) and "sf_location" (attached).

The problem is that the SalesForce error you're describing says the new user account does not have a last name. This is actually true: the user account does not have a last name (or a first name), unless you're giving it a last name using one of the methods described, or something similar.

Once you've given the user a first and last name, then you need to insure that the user gets synchronized with salesforce. The latest "uc_salesforce" code (attached, though not officially released) does this. It is designed to work with the latest "-dev" release of the "salesforce" module (2009-Sep-01).

If you want a fancier solution, add in all of the location-related modules mentioned above. The upside of this is that you get full location integration, which allows you to use GMap, etc. The downside is that it's a little more complex to get going initially, and not fully tested yet, which is why we haven't made many of them official releases yet.

Since Ubercart creates or reuses users automatically when anonymous users place orders, this works out nicely.

We're nearing completion on these connector modules, and will keep you updated.

(also note: in the attached "uc_salesforce.zip", exporting works well, but importing is untested and not quite complete.)

AttachmentSize
uc_salesforce.zip 8.15 KB
uc_profile.zip 1.67 KB
sf_location.zip 1.42 KB
rjacobs's picture
Offline
Joined: 01/05/2010
Juice: 10
Same issue here
Assigned to:bibeksahu» rjacobs

Hi,

We are having the exact same problem as abowers. It just seems like various billing and delivery fields are not available to the salesforce modules when the sync takes place (though they are available, and the sync DOES work, if manually triggering it later via the store admin interface). Like abowers we would like to sync the order billing details into a salesforce contact object.

Though we do generally understand what bibeksahu is saying in the reply, we are still not sure how to solve the problem. We have tried using the updated uc_salesforce.zip and uc_profile.zip but really can't make any progress. With these new modules we always get errors of the form "uc_sf_order_export: invalid fieldmap: -1" or "User Fieldmap found. Not exporting" (despite setting separate user account > salesforce filed mappings, etc.).

Still, the fact that the sync DOES work if done manually later would seem to imply there must be an easier way to make this work. It seems like the order just needs to be COMPLETED before the sync happens. So what about simply turning off the auto-sync option in the fieldmap options and then manually triggering the sync via some php later. Perhaps this could be part of a conditional action within the Ubercart settings (which would also allow a user to determine the exact order status that should trigger the sync).

In this regard, is there some simple php that could be used to manually trigger a sync on an order? I'd love to try inserting this as part of a conditional action to test (custom php is allowed there). I'm not sure how to pick apart the module code to find this (only basic php knowledge here).

Or perhaps someone else has made headway via other means with this kind of situation?

Thanks! Any help greatly appreciated!

Ryan

rjacobs's picture
Offline
Joined: 01/05/2010
Juice: 10
I might have a temporary fix

I think I now have a temporary fix for this scenario using a Ubercart conditional action. However, the more I look at things the more it feels like there must be an easier way to correct this directly in the module code. Perhaps something to do with the hook that's used to call the function that runs the auto export? It seems that when this happens currently, Ubercart simply has not prepared all of the available mapped variables yet, so using a different hook (later in the workflow) might help?

Sorry, I'm just spouting thoughts... my knowledge of these specifics is limited. Perhaps the "new" version (uc_salesforce.zip attached by bibeksahu above) addresses this... I just have not been able to get that version to work at all. So note that my comments below are assuming the version uc_salesforce-6.x-1.x-dev.tar.gz (as on http://www.ubercart.org/contrib/11621 ).

Anyway, I just setup a conditional action to run as soon as an order's status is set to "completed" (IF order status != 'completed' AND updated_order status == 'completed'). Then the action I set was to execute custom php code with the following line:

uc_sf_order_export($updated_order->order_id,2);

(fieldmap 2 is the one we setup for orders).

With this conditional action in place, the export runs successfully and all my fields (including billing/delivery fields) successfully get sent to Salesforce automatically during a transaction.

However, one last thing I noticed is that uc_salesforce does not seem to respect the "Automatically Populate Salesforce" checkbox when setting up a fieldmap (if unchecked, the export still happens automatically, and I end up with two records in salesforce -- one from the auto sync and one from my conditional action). So in uc_sf_order.module I just commented-out the line uc_sf_order_export($order->order_id, $map); in the function uc_sf_order_order (around line 84) to force the auto sunc not to happen.

Anyway, I don't think this is best practice, and this problem may already be solved by other means... I just wanted to note what I did in case that's useful to anyone.

Cheers,
Ryan

bibeksahu's picture
Offline
Joined: 06/09/2009
Juice: 75
updated code
Assigned to:rjacobs» bibeksahu

Hi,

We have updated code that is being used in production at www.booksforlife.org, which is more solid - at least for us.

We are now cleaning up the code and aim to have another development release out soon. I'll try to put a rush on it since people are asking about it.

Basically, we need to verify it against less-patched versions of the "salesforce_api" module than we're currently using. Ideally, I'd like it to work against an unpatched "salesforce_api" dev release - it may, but it's unknown.

Anyway, we'll try to get this out soon.

- Bibek

bibeksahu's picture
Offline
Joined: 06/09/2009
Juice: 75
#5
Project:Ubercart Salesforce Integration» Ubercart Contributions
Category:» task

The new code contains these changes.

http://drupal.org/project/uc_salesforce

(Also see the comments to the Contribution: http://www.ubercart.org/contrib/11621 )

- Bibek