• Resolved rickymortimer

    (@rickymortimer)


    Hi,
    We are having issues with mapped fields that are changed to an empty value (null) in salesforce. When updates are triggered, the existing values in wordpress are not removed.

    We are also finding that the published post is removed until a manual publish is performed.

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

    (@jonathanstegall)

    There’s a similar post here, I think.

    I don’t have a schedule for adding a solution to this, but I do have a GitHub issue you can refer to (pull requests are welcome).

    I’m not sure what you mean by your last sentence.

    Thread Starter rickymortimer

    (@rickymortimer)

    Jonathan,
    Thank you for your reply. I am not sure that it is the same issue.

    I will expand on the issue with an example.

    Scenario:
    I map an object and field in wordpress to salesforce with action triggers Salesforce Create and Salesforce Update and Direction set to Salesforce to WordPress.

    I then create a record on the mapped object and have a value “10” in the mapped field.

    Wordpress creates a new record and sets the field value correctly.

    If I then update the record in Salesforce and set the value in Salesforce to blank, the value does not get set to blank in wordpress. All other updates to the record are made but, the field previously set to “10” is still set to “10” rather than “”.

    We also find that the post is removed from the published website. Our wordpress developer is thinking that is due to the update not being handled correctly but, that may well be a non-related issue.

    • This reply was modified 4 years, 12 months ago by rickymortimer.
    Plugin Author Jonathan Stegall

    (@jonathanstegall)

    Oh, I see. Yes, that is a different issue. It may be that the plugin skips empty values in some cases. I’ll look into this for the plugin’s next release and see if I can duplicate it.

    We are experiencing the same problem. When fields are emptied on the Salesforce side, the wordpress side retains the old value. Is there a fix in the works or could you point me to a hook where I might be able to handle this case? Btw, we love this plugin!
    Thanks

    In function map_params() in salesforce_mapping.php

    we changed the code to check for the case of if we are updating from salesforce and we removed the check for the value being != ” in that case.

    Seems to fix our problem.

    Do you think this is safe or might it have repercussions?
    Thanks

    switch ( $trigger ) {
    case $this->sync_sf_update:
    // Make an array because we need to store the methods for each field as well.
    if ( isset( $object[ $salesforce_field ] ) ) {
    $params[ $wordpress_field ] = array();
    $params[ $wordpress_field ][‘value’] = $object[ $salesforce_field ];
    } else {
    // If we try to save certain fields with empty values, WordPress will silently start skipping stuff. This keeps that from happening.
    continue;
    }
    break;
    default:
    // Make an array because we need to store the methods for each field as well.
    if ( isset( $object[ $salesforce_field ] ) && ” !== $object[ $salesforce_field ] ) {
    $params[ $wordpress_field ] = array();
    $params[ $wordpress_field ][‘value’] = $object[ $salesforce_field ];
    } else {
    // If we try to save certain fields with empty values, WordPress will silently start skipping stuff. This keeps that from happening.
    continue;
    }
    break;
    }

    Plugin Author Jonathan Stegall

    (@jonathanstegall)

    @csyoung I’d be interested to hear whether that works. I don’t think it will, since the original issue was that WordPress was silently skipping things it should’ve saved that came from Salesforce.

    I am not positive on this, but I think probably it will have to do something like this:

    1. Check to see if the Salesforce value is empty before saving it in WordPress
    2. If it is, check to see if there’s already a value for it in WordPress
    3. If there is, delete it if it’s a meta field, and clear the value if it’s a core field.
    4. Probably will also have to check and see if it’s a required field, and do something different if it is.

    There has been a GitHub issue for this for some time, here: https://github.com/MinnPost/object-sync-for-salesforce/issues/275

    I am not sure when I’ll be able to get to this, since I do think it’s quite complicated. But help is welcomed.

    Plugin Author Jonathan Stegall

    (@jonathanstegall)

    @csyoung I’ve got a fix for this issue, I think. There’s a pull request for it here: https://github.com/MinnPost/object-sync-for-salesforce/pull/346 if you’ve got the inclination to test it.

    I’ve got a few other small fixes to test and then hopefully will release a plugin update and mark this issue as resolved at that time.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Salesforce Null handling’ is closed to new replies.