• Resolved chriscostanza

    (@chriscostanza)


    Hello,
    I’m very excited to use this plugin and thanks for taking the time to develop it.

    I’m running into an issue though when I click the “connect to salesforce” button I am taken to Salesforce and I login to our account successfully and it takes me back to the plugin authorization page, but the “connect to salesforce” button remains. I checked the connection log in salesforce and it shows that I connected successfully. Have you seen this happen before?

    Thanks

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

    (@jonathanstegall)

    @chriscostanza I haven’t seen this error before, but I do remember that someone else had it in one of these support threads. Check this topic and see if it is relevant.

    But basically, if I recall, when this person activated the plugin it was not creating the correct MySQL tables in the database. I’ve seen this happen on some hosts. I assume it’s a permission issue but I haven’t been able to replicate it so I’m not sure.

    In any case, I would try that first: check your database (if you have access to it) and make sure there are two new tables: wp_object_sync_sf_field_map and wp_object_sync_sf_object_map.

    If either is missing, here’s the SQL they require:

    
    CREATE TABLE wp_object_sync_sf_field_map (
      id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
      label varchar(64) COLLATE utf8mb4_unicode_520_ci NOT NULL DEFAULT '',
      name varchar(64) COLLATE utf8mb4_unicode_520_ci NOT NULL DEFAULT '',
      wordpress_object varchar(128) COLLATE utf8mb4_unicode_520_ci NOT NULL DEFAULT '',
      salesforce_object varchar(255) COLLATE utf8mb4_unicode_520_ci NOT NULL DEFAULT '',
      salesforce_record_types_allowed longblob,
      salesforce_record_type_default varchar(255) COLLATE utf8mb4_unicode_520_ci NOT NULL DEFAULT '',
      fields longtext COLLATE utf8mb4_unicode_520_ci NOT NULL,
      pull_trigger_field varchar(128) COLLATE utf8mb4_unicode_520_ci NOT NULL DEFAULT 'LastModifiedDate',
      sync_triggers text COLLATE utf8mb4_unicode_520_ci NOT NULL,
      push_async tinyint(1) NOT NULL DEFAULT '0',
      push_drafts tinyint(1) NOT NULL DEFAULT '0',
      weight tinyint(1) NOT NULL DEFAULT '0',
      version varchar(255) COLLATE utf8mb4_unicode_520_ci NOT NULL DEFAULT '',
      PRIMARY KEY (id),
      UNIQUE KEY name (name),
      KEY name_sf_type_wordpress_type (wordpress_object,salesforce_object)
    ) ENGINE=InnoDB;
    
    
    CREATE TABLE wp_object_sync_sf_object_map (
      id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
      wordpress_id varchar(32) COLLATE utf8mb4_unicode_520_ci NOT NULL,
      salesforce_id varbinary(32) NOT NULL DEFAULT '',
      wordpress_object varchar(128) COLLATE utf8mb4_unicode_520_ci NOT NULL DEFAULT '',
      created datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
      object_updated datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
      last_sync datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
      last_sync_action varchar(128) COLLATE utf8mb4_unicode_520_ci DEFAULT NULL,
      last_sync_status tinyint(1) NOT NULL DEFAULT '0',
      last_sync_message varchar(255) COLLATE utf8mb4_unicode_520_ci DEFAULT NULL,
      PRIMARY KEY (id),
      UNIQUE KEY salesforce (salesforce_id),
      UNIQUE KEY salesforce_wordpress (wordpress_object,wordpress_id),
      KEY wordpress_object (wordpress_object,wordpress_id),
      KEY salesforce_object (salesforce_id)
    )
    
    • This reply was modified 7 years, 9 months ago by Jonathan Stegall. Reason: sql formatting?
    • This reply was modified 7 years, 9 months ago by Jonathan Stegall. Reason: sql formatting?
    Thread Starter chriscostanza

    (@chriscostanza)

    Thanks for the quick reply. I was able to verify that those tables were created and have data in them.

    wp_object_sync_sf_field_map – 48k
    wp_object_sync_sf_object_map – 80k

    Can you elaborate on what you were thinking when you mentioned a permission issue. Thanks.

    Plugin Author Jonathan Stegall

    (@jonathanstegall)

    @chriscostanza Well, permissions can be the reason if there are not two database tables. But you seem to already have those, so I expect that is not the issue.

    Here’s how the authentication flow works, in case there’s something relevant in there. When the Authorize tab loads, the plugin checks:

    1. If there is a code parameter on the URL that came from Salesforce. That is, if the /wp-admin/options-general.php?page=object-sync-salesforce-admin&tab=authorize URL has &code=something. If it does, it passes that data back to the Salesforce API and verifies it, after which the page reloads (via JavaScript) and that button goes away.
    2. If there is not a code parameter, it checks to see whether it has already been authorized. This means there is a consumer key and a consumer secret (both of which are stored in the Settings tab) and also a refresh token stored in the database (which is stored in #1). If all if this works, it shows some basic info about the SF install.
    3. If it has not already been authorized, it checks to see whether the Salesforce API object exists, and whether there’s a consumer key and a consumer secret (as in #2). If there is, it shows the Connect to Salesforce button, which sends an authorization code request to Salesforce when it is clicked (as in #1).
    4. Otherwise it shows a missing credential message.

    So here are some things you might do:

    1. You could try disabling JavaScript, and see what exactly the URL is that you are brought back to after logging in to Salesforce. It’s possible that the code parameter is not correct, and so the plugin is unable to save the token.
    2. It’s also possible that there is a JavaScript error somewhere; maybe it is unable to redirect to the correct success URL. That part has a one-time use; if it is unable to save a token it won’t work when the page is reloaded.
    3. You might also have a mismatched setting somewhere; I would just verify that they all match what they’re supposed to be between Salesforce and WordPress.
    4. You could also check PHP error logs on your server and see if anything is in there.

    Hey you guys, I had the same issue. You were right in that it was a permissions error. I check the url after clicking the authorize button and it said the user does not have permission to access this app. I went into my permissions and searched for the app I created in SF and then added that app to my permissions. Viola.

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

The topic ‘Connect to Salesforce button not changing’ is closed to new replies.