Hi there. First of all thanks for the excellent module and support.

I managed to have salesforce and drupal talk to each other after following the instructions in the Readme file and got salesforce to send outbound messages to drupal as per http://drupal.org/node/500052

My problem lies to the fact that even though I can get Events, Opportunities and Tasks from Salesforce to correctly import and create nodes in drupal using the module's Import functionality, I can not get it to import Quotes from Salesforce which is really what we are interested in. When I try to import quotes, either using the import functionality, or the outbound messages from 500052 the correct amount of nodes are created/updated but they are empty!!! Completely empty nodes without even a title (mapped 'quote name' to the title field).

I am using the latest dev of the module and Ctools 1.7.

I went through the issue queue but I couldn't find a similar issue. Apologies though if it has been covered somewhere else and I missed it.

I also tried the Salesforce Feeds module unfortunately with the same results.

Any help or points towards the right direction would be greatly appreciated.

Thanks,
Pavlos

Comments

aaronbauman’s picture

a few things to check:
- are you sure you added all the fields from the Quote object to the outbound message?
- obviously the Workflow is active, or you wouldn't have any nodes created, but that's another common pitfall
- check your watchdog logs to see if there are any errors relating to the node_save()
- when you're trying to debug notifications, obviously dpm() doesn't work. i usually put a bunch error_log() or watchdog() calls into sf_notifications.
If the two checks above fail, can you please add such a message right after:

  $content = file_get_contents('php://input');

in sf_notifications_endpoint() so that it becomes something like

  $content = file_get_contents('php://input');
  watchdog('sf_notifications', '<pre>' . print_r($content, 1) . '</pre>');

Censor our any sensitive info, and post the result here

pavlosdan’s picture

Hi aaron thanks for the help and pointers.

- All fields were added
- Workflow is activated
- No node_save() watchdog logs

As I thought that it was strange that all other types of content from Salesforce was being imported ok except quotes, I started a new project and set up the module again just with the bare minimum it required to work. This time the sf_imports worked ok with quotes being imported correctly according to the mapping I had set. (though I noticed that the drupal messages always say 'Created' even when importing quotes that are already there - prematching rules are set).

This time though sf_notifications doesn't seem to work as when I create something on SF, its not being created in Drupal. I checked and the packets do come through from SF through the network and onto my machine. I've added the watchdog message in the sf_notifications module but no messages were logged other than one that was being logged already which is saying 'Access denied to IP address ... in attempt to access sf_notifications/endpoint.' where the IP address is my local machine's IP (my dev is on a VM). This is strange though as I already added the IP address to the allowed white list. Could there be something wrong there?

The outbound messages are set so that the endpoint URL is: http://baseurl
Do I need to set it to http://baseurl/sf_notifications/endpoint?

The patch that I used to get the sf_notifications module was: http://drupal.org/files/issues/500052-37-sf_notifications.patch

Thanks,
Pavlos

kostajh’s picture

Hello Pavlos,

Sounds like a problem with the IP whitelisting. On line 46 of sf_notifications.module, add "return TRUE;" to the very beginning of the sf_notificiations_allowed_ips() function (you can leave the rest of the code below that alone). It should look something like this:

/**
 * Access callback for SALESFORCE_PATH_NOTIFICATIONS_ENDPOINT
 *
 * @return TRUE if IP is in whitelist and FALSE if not.
 */
function sf_notifications_allowed_ips() {
  return TRUE;

By always returning TRUE, you can see if the problem is with the IP whitelisting or if the problem resides elsewhere.

Also, you are correct that the outbound messages should be set to http://baseurl/sf_notifications/endpoint, not http://baseurl

-Kosta

pavlosdan’s picture

Thanks for the help guys.

I deployed the site on a staging environment to make sure that no traffic was being blocked from salesforce to the site. The outbound messages now seem to get through correctly and the watchdog started to record the error messages which I guess is one step forward.

The recorded message from the watchdog when something was created on salesforce was:

Warning: require_once(sites/[SITENAME]/modules/contrib/salesforce/salesforce_api/toolkit/soapclient/SforcePartnerClient.php) [function.require-once]: failed to open stream: No such file or directory in sf_notifications_endpoint() (line 112 of /mnt/www/[SITENAME]/html/sites/[SITENAME]/modules/contrib/salesforce/sf_notifications/sf_notifications.module).

I had a look in the sf_notifications.module at line 112 where the line read:
require_once(drupal_get_path('module', 'salesforce_api') .'/toolkit/soapclient/SforcePartnerClient.php');

this didnt look right as I am using the libraries module so the soapclient is actually in my sitefolder/libraries folder and not inside the actual salesforce module.

I changed the line to:
require_once(SALESFORCE_DIR_TOOLKIT . '/soapclient/SforcePartnerClient.php');
which seemed more correct as the directory of the toolkit is already being defined in the salesforce_api.module (line 15).

This made the watchdog stopped recording the errors about not being able to find the file (assuming that its finding it ok now). But the nodes associated with the salesforce type are still not being created.

Did anyone try the sf_notifications module with the library inside the libraries folder instead and got it working?

Cheers,
Pavlos

aaronbauman’s picture

Pavlos,
Looks like you're using an older version of sf_notifications.
The latest version that I have been using on a staging site is #500052-39: Allow salesforce to initiate imports.

You will probably want to subscribe to 500052 since this is still under very active development.

pavlosdan’s picture

On a site note I had changed the endpoint URL to not include the 'sf_notifications/endpoint' at the end...

After adding it back, watchdog messages started logging on my site everytime a new item was created on Salesforce. Albeit the messages are always empty though so they are not much help.

Any ideas?

Pavlos

kostajh’s picture

Hi Pavlos,

Did you have to change the IP whitelisting function in comment #3 above? Also, did you add the watchdog statement per comment #1, if so, could you tell us what was logged?

Kosta

pavlosdan’s picture

Hi aaron and kosta. Just upgraded the module to the latest patch: http://drupal.org/node/500052#comment-3912654

After adding back the watchdog logging statement and changed the IP whitelisting function, the watchdog comes up with the following message (same as in #4).

Warning: require_once(sites/[SITENAME]/modules/contrib/salesforce/salesforce_api/toolkit/soapclient/SforcePartnerClient.php) [function.require-once]: failed to open stream: No such file or directory in sf_notifications_endpoint() (line 112 of /mnt/www/[SITENAME]/html/sites/[SITENAME]/modules/contrib/salesforce/sf_notifications/sf_notifications.module).

Should line on 112 be modified as per #4 or should I leave it as is?

After I changed that line, one of the logs gave the following message:

Recoverable fatal error: Object of class stdClass could not be converted to string in is_sfid() (line 59 of /mnt/www/[SITENAME]/html/sites/[SITENAME]/modules/contrib/salesforce/salesforce_api/salesforce_api.module).

aaronbauman’s picture

line 112

require_once(drupal_get_path('module', 'salesforce_api') .'/toolkit/soapclient/SforcePartnerClient.php');

should be

require_once(SALESFORCE_DIR_SOAPCLIENT .'/SforcePartnerClient.php');

Looks like this was excluded from the patch, even though it says it's there.
grumble.

pavlosdan’s picture

Made the change in #9.

watchdog now just records some empty messages.

Also checked the status of the outbound messages on the salesforce side. Im getting Delivery Failures for the following reasons:

  • SOAP response was a nack
  • org.xml.sax.SAXException: Processing instructions are not allowed within SOAP messages
  • org.xml.sax.SAXParseException: Premature end of file.

note... as the issue of importing empty notes has been solved and now the issue is with the sf_notifications, maybe it would be worth closing this support request and continue the conversation in the sf_notifications issue on #500052: Allow salesforce to initiate imports ?

Pavlos

aaronbauman’s picture

Component: sf_node » sf_notifications

I have closed #500052, committed sf_notifications into dev, and updated the component on this ticket - I think it's ok to keep this issue going now until we get to the bottom of your issue, Pavlos.

pavlosdan’s picture

Component: sf_notifications » sf_node

Hi aaron... thanks for your replies.

I 've updated the module to the latest dev snapshot and added the soapclient library to the ..salesforce_api/toolkit/soapclient folder just to try it out.

Note: Line 111 of the sf_notifications.module is still set to
require_once(drupal_get_path('module', 'salesforce_api') .'/toolkit/soapclient/SforcePartnerClient.php');
instead of

require_once(SALESFORCE_DIR_SOAPCLIENT .'/SforcePartnerClient.php'); 

This time the watchdog recorded that the IP that the message was coming from "accessed sf_notifications/endpoint successfully" but no new nodes were created on drupal.

On salesforce the outbound message status is:
org.xml.sax.SAXParseException: Premature end of file.

Any ideas?

BTW in addition to your watchdog message I've also added a few more in the sf_notifications_endpoint() just for testing purposes

e.g:

watchdog('sf_notifications', 'this is a test message recording1');
// Needed for the reference to SObject in parse_message, otherwise it just seems to die
// when it tries to call new SObject()
require_once(drupal_get_path('module', 'salesforce_api') .'/toolkit/soapclient/SforcePartnerClient.php');
watchdog('sf_notifications', 'this is a test message recording2'); 

right after line 107. But this never gets recorded.

'this is a test message recording1' records and show in the logs ok but 'this is a test message recording2' never records which leads me to believe that for some reason the require_once on the soapclient file fails and the execution of the function then stops.

pavlosdan’s picture

Component: sf_node » sf_notifications
pavlosdan’s picture

I think we are moving forward....

The issue was actually the way the outbound messages were set on the Salesforce side.

The Send Session ID was not checked for the configured message so I guess the sf_notifications did not know what to respond to.

Now all the debugging messages are getting recorded by the watchdog. Also being recorded are the details of the message coming through from salesforce.
e.g:

Array
(
    [salesforce] => Array
        (
            [id] => SObject Object
                (
                    [type] => Quote
                    [fields] => stdClass Object
                        (
                            [Id] => id
                            [Description] => an awesome test
                            [Name] => an awesome test
                        )

                    [fieldnames] => Array
                        (
                            [0] => Id
                            [1] => Description
                            [2] => Name
                        )

                    [Id] => id
                )

        )

    [drupal] => Array
        (
        )

)

Remaining: Even though the messages are now coming through with their details, no nodes are being created with those details even though the mapping exists and the sf_import was able to create the nodes with the mass-import.

A php error is being recorded as well and that is:

Recoverable fatal error: Object of class stdClass could not be converted to string in is_sfid() (line 59 of SITENAME/contrib/salesforce/salesforce_api/salesforce_api.module).

Now to get this sorted so that nodes can actually be created with the details coming in from SF.

aaronbauman’s picture

That is an annoying error, but it should not be causing the issue you describe.

Check out notifications settings (i know i know, another settings page) - admin/settings/salesforce/notifications and make sure the fieldmaps you want to respond to notifications are active.

pavlosdan’s picture

Yiap they are set.

pavlosdan’s picture

Issue tags: +yew@yahoo.com

Question: is it normal for the Drupal array (see bottom of quoted php code in #14) to be empty at that point?

I 've checked the admin/settings/salesforce/notifications and that was set. I also checked the field mapping again and noticed that there was a new secondary tabbed there named 'Notifications' (I assumed activating the map from the primary Notifications tab would activate the mapping to respond).

The 'Active' checkbox was checked but the conditions were empty. As I wanted drupal to be updated on any incoming message from salesforce for that Map and also for simple testing I just added: return TRUE; without the tags as instructed.

Following that I run some more tests but without any success. Am I missing something else?

aaronbauman’s picture

Issue tags: -yew@yahoo.com

iirc, the 'drupal' array will be empty if there is no existing linkage between the salesforce object and a drupal object.
in other words, an empty 'drupal' array will trigger an insert rather than an update.

kostajh’s picture

Pavlos, can you describe your fieldmap? What fields are Id, Name, Description mapped to? Also, can you go to admin/content/node and verify that there are no "empty" nodes (nodes without a title).

aaronbauman’s picture

Thanks again for hanging in there, Pavlos.

Now that sf_notifications has been added to the cvs repository, i've been able to do some better testing.
I've committed a few critical, previously unnoticed issues.
They'll be available on the project page in < 12 hours, or you can grab them from CVS now.

Thanks for your work on this everyone.

pavlosdan’s picture

re: #19 makes sense. thanks for explaining that :)

re: #20 The fieldmap is as follows:
- ID is the Salesforce object ID that is coming from salesforce by default. Mapped that one to a free-text field I created with CCK.
- Name is the Salesforce object Name and that is mapped to the Title field of the node.
- Description is the Salesforce object Description field (free-text area) and that is mapped to the Body of the node.
There are no empty nodes in admin/content/node at the moment. That was fixed when I recreated the environment (I suspect that was caused from the caching of the WSDL file when I changed the files, though not very sure as I didn't try to recreate the error).

re: # 21 I will give it a try as soon as possible aaron. Thanks.

Thank you both for baring with me and trying to help me through setting this up. Your help and time is really appreciated.

pavlosdan’s picture

Hi guys... just got a chance to test the latest commit from CVS.

Issue resolved. Drupal nodes are created successfully when an outbound SF messages are received.

Thank you so much for all your help on this.

I 'll continue testing but first results show that this support request can be closed down. :)

Again, many thanks.

aaronbauman’s picture

Status: Active » Fixed

Thank you for your patience with debugging this.
Hopefully others will find this thread useful.

Status: Fixed » Closed (fixed)

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