Support

Account

Home Forums Backend Issues (wp-admin) issues importing content from Salesforce

Solving

issues importing content from Salesforce

  • I’m using this plugin to sync data from Salesforce into our site, specifically ACF fields:
    https://wordpress.org/plugins/object-sync-for-salesforce/

    We’re experiencing some very weird behavior.

    The fields are assigned to a custom post type which are then pulled via a query into a grid layout on a single page.

    On a published post that has already imported data from Salesforce, whenever we update that data in SF, then wait for the object sync cron job, I can see the updated text when that post is open in my browser (wp backend). However, this is then only visible on the front end after manually clicking publish.

    So after reaching out to the object sync dev, he thought maybe there’s some ‘intermediate step’ whereby ACF isn’t actually saving the change to the database, as would occur when clicking update.

    Does this make sense at all? That newly imported data from SF could visibly appear inside the post editor in the backend, but not actually be visible on the front end until manually clicking publish?

    Here’s my support ticket with object sync if that helps: https://wordpress.org/support/topic/syncing-issues-4/

  • I’m not sure I understand completely.

    When a new post is created doing the sync, what happens?

    When an existing post is updated and fields that did not have values are populated, what happens?

    When an existing post is updated and existing data is altered, what happens?

    What type of fields are they?

    Are the fields sub fields of other field types (group, repeater, flexible content)?

  • When a new post is created doing the sync, what happens?

    First round is that it creates a draft, which is normal for the plugin.

    When an existing post is updated and fields that did not have values are populated, what happens?

    I can see the new text when viewing the post in the back end, but it does not become visible on the front-end until manually clicking publish.

    When an existing post is updated and fields that did not have values are populated, what happens?

    Same as above.

    What type of fields are they?

    Text and text area. Not sub-fields.

    Just did another test… a post listed as being published:
    https://sanktoberholz.de/wp-content/uploads/2021/09/Screen-Shot-2021-09-06-at-4.24.39-PM.png

    And yet isn’t visible via post query until I hit Update again. Here’s the post query that I’m using, which shows a meta query for displaying only those that have been marked as a specific category (in Salesforce, not a WP category) and a checkbox for whether to make the post visible. (Its for a rudimentary inventory management process.)

    
    			<?php
    				$args = array( 'posts_per_page' => -1,  'post_type' => 'assets',
    
    				'meta_query'	=> array(
    						'relation'		=> 'AND',
    						array(
    							'key'		=> 'area',
    							'value'		=> '["MITTE"]',
    							'compare'	=> '='
    						),
    						array(
    							'key'		=> 'show_on_website',
    							'value'		=> 1,
    							'compare'	=> '='
    						)
    					)
    				);
    
    				$myposts = get_posts( $args );
    
    				if($myposts):
    
    				foreach ( $myposts as $post ) : setup_postdata( $post );
    
     			?>
  • I don’t know what the problem could be from the information you have supplied. Generally, when there is an issue with content not being shown on the front end when the values in ACF are present in the admin is that the field key reference in the DB is not added correctly and this can happen when importing fields.

    What is the field key reference? For every field in ACF, for example “my_field” the meta key for this field is created based on the field name and a second associated field is created that is the field name preceded by an underscore (“_{$field_name}”. This allows ACF to look up the field settings for the field value.

    However, this is not generally an issue with text based fields where a single text value is saved for the field name. It can be an issue when text base fields are sub fields of another field.

    If the values are being populated to the DB under the correct meta key and they are text based fields and they are not sub fields then I haven’t got a clue what the issue could be.

    My next step would be to look in the database to see exactly what is being stored and where it is being stored and that it is in fact saved for the correct post ID.

  • Thanks @hube2 .

    Any tips about where in the DB to look? I remember trying to find ACF fields in the past and got lost looking, also in the documentation.

    Maybe this helps… after another round of testing (with debugging turned on) I see these errors:

    [08-Sep-2021 13:57:35 UTC] PHP Notice: Trying to get property ‘ID’ of non-object in /www/htdocs/w01a2ea9/sanktoberholz.de/wp-includes/class-wp-query.php on line 4044
    [08-Sep-2021 13:57:35 UTC] PHP Notice: Trying to get property ‘post_title’ of non-object in /www/htdocs/w01a2ea9/sanktoberholz.de/wp-includes/class-wp-query.php on line 4046
    [08-Sep-2021 13:57:35 UTC] PHP Notice: Trying to get property ‘post_name’ of non-object in /www/htdocs/w01a2ea9/sanktoberholz.de/wp-includes/class-wp-query.php on line 4048

    Looking at class-wp-query.php this appears (to my limited understanding) to be the code referenced when making queries in template files. Could this help explain why the post sort of “disappears” to the post query, although it is still visible (and marked published in the backend)?

  • They will be in the postmeta table. post_id == your post ID and meta_key == the field name.

    If you don’t find the updated data then the import could be a draft post. In this case the data could be attached to a different post ID and this post ID will be a child post of the real post ID. You can look for this by looking for posts where the post_parent is the real post ID.

    The errors tell me that it is trying to update a post that does not exist, but I have no idea why it would be doing that.

Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.