Support » Plugin: Object Sync for Salesforce » Create new post in wordpress from salesforce

  • Resolved grayzee

    (@grayzee)


    Hello,

    im trying to create new posts in WordPress within a custom post type when a SF object such as a contact is created or updated in Salesforce.

    So far im having some issues with this and wondering if there are some fields that I need to specifically match up to ensure the WP Posts are created when Salesforce is updated.

    Many thanks,
    Graeme

Viewing 12 replies - 1 through 12 (of 12 total)
  • Plugin Contributor Jonathan Stegall

    (@jonathanstegall)

    It depends on your custom post type. If the custom post type has required fields (for example, post_title) you’ll need to make sure those fields are sent from Salesforce.

    Thread Starter grayzee

    (@grayzee)

    I have created some custom fields via ACF but none of them are set to required…

    Thread Starter grayzee

    (@grayzee)

    Hello, Me again…

    So iv created a new CPT with only the following available to make sure no ACF fields are blocking the creation of the WP Post.

    CPT: “supports” => [ ‘title’, ‘editor’, ‘thumbnail’, ‘excerpt’ ],

    So in theory the post should be created when I create a new contact in SF with the field mapping of WP – Post_title mapped to SF – last name?

    Wordpress Field maps: https://ibb.co/3p6LQYS
    SF create new contact: https://ibb.co/FJ95FtJ

    Any ideas why this is not working? I can send data to SF on this test setup from users and another CPT if the record exists in WP already how ever if the record does not exist in WP then salesforce does not create a post or send data to WP that i can see?

    Nothing appears in the WP logs either?

    Plugin Contributor Jonathan Stegall

    (@jonathanstegall)

    I think it should work, yes. You will probably want to turn on debug mode and see what kind of log entries it creates. Don’t leave it on long term as it creates a lot of entries, but it will hopefully be helpful to show what API calls the plugin is actually sending to Salesforce.

    Thread Starter grayzee

    (@grayzee)

    https://ibb.co/z2W1x7b all logs are enabled but nothing appears in the log list when i create a new contact in SF. Iv set permissions to all on the SF connected application.

    I cant work out why i can send to SF but i cant send to WP if the post does not already exist? Weird how no logs are created also?

    Plugin Contributor Jonathan Stegall

    (@jonathanstegall)

    I think if no logs are created, your scheduling is probably not working correctly. I noticed on your earlier screenshot that your tasks to send data from WP -> SF are not set to process asynchronously. That is fine, of course, but what it means is that it doesn’t run through the backend scheduler. All data that comes from SF -> WP does run through the backend scheduler because it has to run scheduled tasks to check for new/updated data, and then run additional tasks to process that data.

    It’s hard to say what might be wrong with the scheduling, but some places to start:
    1. Make sure the scheduling tab of the plugin has the settings you expect it to have.
    2. Install a plugin that checks on your cron status. WP Crontrol is a good option.
    3. This plugin also provides a place to see all of the actions that it runs. It is not always helpful, but you can access it at the /wp-admin/tools.php?page=action-scheduler URL of your WordPress install.

    I will say that I’d try #1 and then #2 because if your server’s cron is having problems, #3 won’t show anything helpful.

    Thread Starter grayzee

    (@grayzee)

    hello

    in the fieldmap page i have now enabled the Process Asynchronously option.

    in the schedule section of the plugin when i set a run schedule entry time and set the time unit to minutes and click save both values revert back to unset as the image displays.

    https://ibb.co/rxXpBmz

    I cant work out why it wont save a value.

    I also installed cWP Crontrol and this is what i can see https://ibb.co/3M8zJLw

    I cant see anything related to salesforce or object sync?

    Plugin Contributor Jonathan Stegall

    (@jonathanstegall)

    1. You don’t have to enable process asynchronously, that is only for pushing data. If pushing already works without running on a schedule and doesn’t cause you capacity problems, you don’t have to change that. Whatever you like is fine for that.

    2. If you can’t overwrite the settings, that is a problem and it may be related to what is happening for you. Your server might have PHP errors or something else that shows why it would prevent things from being saved in wp_options. You might have to manually clear those values. They’re stored in fields like object_sync_for_salesforce_salesforce_pull_schedule_number and object_sync_for_salesforce_salesforce_pull_schedule_unit. The plugin won’t run its schedules without a value in those fields, in any case.

    3. The screenshot you have for WP Crontrol is not a WP Crontrol screenshot (#2 in my earlier suggestion), it is from the scheduled actions page that Action Scheduler creates (#3 in my earlier suggestion). Different plugins. Cron is what Action Scheduler uses to process its actions. So you may want to look at both.

    4. In any case, several of the actions on your screenshot are actually related to this plugin, they’re the ones that start with object_sync_for_salesforce. It looks like they haven’t run in some time, which may be related to your issue with the scheduling settings.

    I think I would try to get those schedule settings working properly first and then see if that resolves the overall problems.

    Thread Starter grayzee

    (@grayzee)

    1) ah ok i have removed this now as its not needed.

    2) weirdly enough when returning to this today the value had changed to what i set it to and when checking the DB it has the value i set it to… so all good here.
    5 minutes is what the db entries contain.

    3) ah ok i see… so when looking at the Cron Events list… which is created by the plugin? I cant see anything for object sync? is this an issue?

    screencapture-sftestcase-wpengine-wp-admin-tools-php-2022-03-04-09-30-46

    When i navigate to /wp-admin/tools.php?page=action-scheduler i can see two tasks for object sync but they are set to non-repeating and have now run in a month? how can i resolve this?

    Plugin Contributor Jonathan Stegall

    (@jonathanstegall)

    Cron is probably fine, the action_scheduler_run_queue is the one that processes things for this plugin.

    So my guess is that the problem is that the tasks in Action Scheduler are not running. The one that’s called object_sync_for_salesforce_pull_check_records has to run for the plugin to see if there is new data in Salesforce.

    I can’t speak to what is wrong with it, but I think that’s where you should put your energy. Some things to try:

    1. Change the schedule settings to something else and see if it starts running again.
    2. Uninstall the plugin and reinstall it without deleting its data (do a backup of the settings first). See if reinstalling it starts up the tasks again.
    3. Uninstall the plugin and let it delete all of its data (but export the fieldmaps/object maps first so you can re-import those things). See if that starts up the tasks again.

    Otherwise, you may need to speak to your host, or find a developer/agency who can dig into that more deeply.

    Thread Starter grayzee

    (@grayzee)

    I managed to get what i was trying to doing working by starting over.

    I started created a fresh wp install, created some custom fields within a cpt and linked it all up… works fine. Something in my original theme is blocking it from working.

    I was able to create posts in WP from salesforce contacts without issue but now im trying to create WP users from the creation of a SF contact.

    Is there anything specific within the field mapping that I need to consider when trying to do this? So far iv not had much luck and the error logs are just spitting out a load of API info? Nothing really suggesting what im doing wrong?

    Plugin Contributor Jonathan Stegall

    (@jonathanstegall)

    Well, if it’s not working you should be using the logs to troubleshoot (assuming that you’ve enabled debug mode, you’ll see a lot of logs and it does indeed take work to sort through them). Some ideas:

    1. What API info is it logging when it runs? Is it retrieving the right set of contacts? Presumably it should be retrieving the same set of contacts twice, if you’re running two fieldmaps off the same Salesforce object. If it isn’t doing that, something in your setup must be preventing it.
    2. If it does retrieve the correct contacts, does it log that it adds them to the queue for processing? Again, I’m guessing it should do this twice for each record since it’s the same object.
    3. Once it adds them to the queue, it should be able to process them unless it runs into erorrs. Errors could be anything from missing required fields to server errors to fields that aren’t mapped correctly.

    I’m sure you can find other ways to debug, but that is where I would start.

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Create new post in wordpress from salesforce’ is closed to new replies.