[BUG] Addon doesn’t use the api_name but modified field_label instead
-
Hello,
I’ve recently installed the addon onto my website and it doesn’t work properly.
My use for it was just to insert new contacts. But i believe this bug affects all the types of processors.To the problem. When the addon make a API call to Zoho the json looks something like this:
{ "data":[ { "Full_Name": "Mr. My Name", ... } ], "trigger":[ ] }
The the problem is with the “Full_Name” json key. It’s generated from the field_label json key which is seen as the label in the processor settings. (“Full Name” we replace ” ” with “_” and we have “Full_Name”). But that’s not the right way. The addon gets the field_label from another API request to zohoapis.com/crm/v2/settings/fields?module=… In the same request. In the same object as field_label is also another json key api_name. And that’s the right string to use.
Why is this a problem? When a user changes name of some field on Zoho (as I did). It will logically affect the key generated by addon. For example: If I were to change “Full Name” to just “Name” the json sent by addon would change like this:
{ "data":[ { "Name": "Mr. My Name", ... } ], "trigger":[ ] }
But Zoho API sets the expected api_name when you create the field and then it stays the same. So basically the json key is wrong, there’s no field by that api_name and therefore it just ignores it. The result is that, some part of your form gets imported and some (the fields you’ve changed the name of) parts don’t.
I’ve gone though the code and I belive to fix this you just need to change code in this file ( /includes/class-cf-processor.php ) at line 450. Instead of this:
$label = str_replace( ' ', '_', $field['field_label'] ); /** * TODO: Change this to a preg_match */ if ( 'Lead_Owner' === $label || 'Task_Owner' === $label || 'Contact_Owner' === $label ) { $label = 'Owner'; } $label = str_replace( '.', '', $label ); $object[ $label ] = $this->get_form_value( $field );
I believe there just needs to be this:
$object[ $field['api_name'] ] = $this->get_form_value( $field );
I haven’t tested it though.
Thank you
Brona Ruzicka
- The topic ‘[BUG] Addon doesn’t use the api_name but modified field_label instead’ is closed to new replies.