• Resolved aballmg

    (@aballmg)


    I want to make sure I’m approaching this correctly:

    • We are only pulling from Salesforce to WP; we are not pushing
    • We have a custom post type (doctor)
    • We have a custom field on that post type to store the Salesforce Account ID
    • We have existing content that mirrors the Salesforce content but has been entered manually in the past; this project is intended to switch to managing the data in Salesforce and syncing it down to WordPress.

    We have two fieldmaps:

    1. One is triggered when the Salesforce account is modified and is supposed to prematch the WP custom field with the Salesforce Account ID.
    2. The other is triggered when an object on that account in Salesforce containing hospital assignments is modified or created, and is supposed to prematch the WP custom field with the object’s “Account__c” field which should be the same as the main Salesforce Account ID to which the object is attached.

    In both cases, the prematching does not seem to take place and a new post is created in WordPress instead.

    We have tried using object_sync_for_salesforce_find_wp_object_match and object_sync_for_salesforce_pull_mapping_object to no avail.

    If we instead use the post_title field to store the Salesforce Account ID in WordPress and we prematch on that, the object mapping is created correctly and uses the post ID of the existing matching WordPress post.

    Is this an issue with the fact that it’s trying to prematch on a meta field instead of a core post field?

    We would prefer to keep the name as the post title, and to not match on the name because of chances of errors or incorrect mapping if there’s more than one John Smith, for example.

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

    (@jonathanstegall)

    Ultimately, when it’s saving into a post type, the plugin *should* be running a WP query with a meta_query array that contains the key and value of the prematch. If the custom field can be retrieved that way I think it should be able to prematch.

    I’m inclined to think you have a few options:

    1. Find out exactly what query WordPress is running when it tries to do the prematch. I won’t pretend it’s not a big convoluted, but here is the method the plugin uses.
    2. Make sure your meta field is accessible by the method the plugin runs, OR you could potentially submit a pull request to expand how it’s working.
    3. If none of that works, I think you could consider storing the Salesforce Account ID as the post slug instead, since the slug is stored in wp_posts as the unique post_name value.

    Plugin Author Jonathan Stegall

    (@jonathanstegall)

    @aballmg someone submitted a bug and a pull request related to this issue and I think it may help you. Can you try upgrading to version 2.2.3 and see if it works?

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Issues prematching on custom field (post_meta)’ is closed to new replies.