MinnPost / object-sync-for-salesforce

WordPress plugin that maps and syncs data between Salesforce objects and WordPress objects.
https://wordpress.org/plugins/object-sync-for-salesforce/
GNU General Public License v2.0
94 stars 51 forks source link

Meta fields can't be accessed unless they already exist in the database #119

Open jonathanstegall opened 6 years ago

jonathanstegall commented 6 years ago

When you go to create a fieldmap, if the WordPress object you are mapping has custom meta fields (such as wp_postmeta, wp_termmeta, etc.) each field will only show up in the dropdown for mappable fields if there is at least one value in the database for that field.

That is, if you want to map a user zip code, you have to have at least one user that has at least a blank value for zip code.

This is not easy to address because:

  1. The database does not store a list of all meta fields; our current query gets distinct fields that have values.
  2. The WordPress codebase for meta fields does not store a list of all meta fields.

Either of these would fix this problem. I am not sure whether such a thing is in the scope of this plugin, but I want to put it out there anyway.

jonathanstegall commented 6 years ago

I haven't tested the Fields API, but it is possible that this would be worked out if #44 is ever a reality.

jonathanstegall commented 6 years ago

This becomes especially problematic if people create a fieldmap and then need to add more fields to it, because the plugin caches the data and we don't have a specific way to clear it.

We need to think about how to clear that specific field, I think. That is not as hard a problem to solve as #106 is.

jonathanstegall commented 6 years ago

The above pull request addresses this issue only if it is caused by cache.

jonathanstegall commented 6 years ago

This issue was first mentioned in #110 as part of a WooCommerce question, which itself was at least partially fixed in #118.

jonathanstegall commented 6 years ago

We also need to put in some documentation about this. Documentation is totally not a fix for this issue, as I think it is hard to even imagine this as an issue, but at least we can point to an explanation when users are understandably confused.

jonathanstegall commented 6 years ago

We could at least show this on the fieldmap add screen as help text, close to the WordPress field picker.

jonathanstegall commented 6 years ago

We have a branch for this issue now. https://github.com/MinnPost/object-sync-for-salesforce/tree/119-new-meta-fields

jonathanstegall commented 5 years ago

The reason I mentioned this is that this issue is deeper still, in which meta fields don't get added when an object is created, but after as a subsequent update.