• Resolved hodyhong

    (@hodyhong)


    Hi there, firstly thanks for your plugin. It has been great.
    I was able to sync between WP and SF with existing users and contacts. However while I have configure the pushing and pulling trigger when a user is created in WP or when a contact is created in SF, things did not go correctly.
    When a new user in WP is created, the user was to connected to a tmp SF ID. It does not exist. The log simply shows “HTTP Method ‘PATCH’ not allowed. Allowed are GET,HEAD,POST”
    and

    
    URL: https://ap15.salesforce.com/services/data/v44.0/sobjects/Contact/Id/
    Message: HTTP Method 'PATCH' not allowed. Allowed are GET,HEAD,POST
    Code: 405
    

    And when I create a new contact in SF, WordPress simply doesn’t do anything at all. No pulling nor error what so ever.

    Would you be able let me know what might have caused it.

    Thanks a lot.

    Cheers

    Hody

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author Jonathan Stegall

    (@jonathanstegall)

    @hodyhong I’m not sure what your issue might be.

    The reason for the tmp SF ID is this: when a new WordPress record is created, it maps to a temporary ID while it waits for a response from the Salesforce API. If it gets a successful response, it updates the fieldmap to the new ID.

    The error log you pasted is what happens when the plugin assumes the record already exists, and that it is being updated. So it fails, I think, because it doesn’t have an ID to try.

    So I’m curious if you have other error logs, either in the log posts for the plugin or on your server itself. If the API is failing, you should have an initial error message in there somewhere.

    Thread Starter hodyhong

    (@hodyhong)

    Hi Jonathan,

    Thanks so much for your reply. It is indeed quite odd. I couldn’t locate any other error log identifying the API failing. Is there anyway that I might be able to place an interrupt or some sort, so that I can see what may have cause this.

    Would Salesforce have some error log somewhere?

    Cheers

    Hody

    Plugin Author Jonathan Stegall

    (@jonathanstegall)

    @hodyhong I’m not very familiar with how Salesforce logs API calls. I think it can, but I’m not sure if it does it automatically or if you have to ask for it to do so.

    As for placing an interrupt, sure. I think that’s possible.

    1. You can turn on debug mode in the plugin settings. This may create a lot of log entries. Mainly it tries to log all of the Salesforce API calls (some of them are cached, so it’s not always accurate that every log entry is actually a new API call).
    2. You could try switching Salesforce Push from async to not async (or the other way around) on the fieldmap settings. You can’t do this with pull, but if you try it with push and it has any different results, at least this could help isolate the problem.
    3. If neither of those give you anything revelatory, you could try placing some debug code into the plugin classes. For example, in classes/salesforce_push.php, at line 399 (of the most recent version) this method prepares records from WordPress that should be sent to the Salesforce API and either adds them to the queue or processes them directly. You could add several error_log calls here. For example you could add an error_log( 'the object data is ' . print_r( $object, true ) . ' and the object type is ' . $object_type ); to line 401.
    4. You could do something similar in classes/salesforce_pull.php. Line 206 processes the records that have been created or updated in Salesforce. So for example you could add error_log( 'api call is ' . (string) $soql . ' and response is ' . print_r( $response, true ) ); to line 257 and see what exactly the plugin is asking for from Salesforce and what its response is.

    Thread Starter hodyhong

    (@hodyhong)

    Thanks Johnathan, let me give it a go and report back. Cheers

    H

    Thread Starter hodyhong

    (@hodyhong)

    I have another server error log in the home folder, which shows the following:

    [17-Jan-2019 15:21:16 UTC] WordPress database error Duplicate entry '' for key 'salesforce' for query UPDATE 'wp2018_object_sync_sf_object_map' SET 'id' = '589', 'wordpress_id' = '589', 'salesforce_id' = NULL, 'wordpress_object' = 'user', 'created' = '2019-01-18 02:21:14', 'object_updated' = '2019-01-18 02:21:14', 'last_sync' = '2019-01-18 02:21:14', 'last_sync_action' = 'push', 'last_sync_status' = '1', 'last_sync_message' = 'Mapping object updated via function: salesforce_push_sync_rest' WHERE 'id' = '589' made by do_action_ref_array, WP_Hook->do_action, WP_Hook->apply_filters, call_user_func_array, ActionScheduler_QueueRunner->run, ActionScheduler_QueueRunner->do_batch, ActionScheduler_Abstract_QueueRunner->process_action, ActionScheduler_Action->execute, do_action_ref_array, WP_Hook->do_action, WP_Hook->apply_filters, call_user_func_array, Object_Sync_Sf_Salesforce_Push->salesforce_push_sync_rest, Object_Sync_Sf_Mapping->update_object_map

    I think the Duplicate Entry is one of the issue at fault. Do you have any idea what may have cause this?

    • This reply was modified 5 years, 10 months ago by hodyhong.
    • This reply was modified 5 years, 10 months ago by hodyhong.
    Plugin Author Jonathan Stegall

    (@jonathanstegall)

    @hodyhong I’ve never seen that error. But here’s how I would assume that it is happening:

    1. The plugin sees some data that it should push to Salesforce. It creates an object map row with the temp ID.
    2. The plugin seems to think it has gotten back a response from Salesforce, so it tries to update the object map row.
    3. But the ID field is apparently empty each time, so it fails to have more than one error row.

    Again I’ve never seen this issue, so I don’t know more about why it’s happening.

    Thread Starter hodyhong

    (@hodyhong)

    Strangely, after updating to version 1.6 (I only just realise I was behind), the Unsert Salesforce Contact error has become a success message. Even though there is no Salesforce Contact being created. The above error only started to occur after ugrading the plugin to version 1.6, whenever there is a new user created in WP.

    Thread Starter hodyhong

    (@hodyhong)

    @jonathanstegall I found the reason!
    Apparently, previously I have checked “Prematch” on one of the custom field to prematch the contact ID. This may have caused the problem, as there is no value in the custom field to prematch from. And with the “prematch” checked, the contact cannont be created in salesforce. I unchecked and user has been created successfully. Bingo!

    Now creating contact in SF still didn’t get sync over in WP. I will play with the interrupt and see what I can find.

    Cheers
    H

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘WP to SF and SF to WP Create issue’ is closed to new replies.