When the code brings back the field for each object it is storing it in an array, but leaving out the object that the field actually belongs to. In certain cases, the SalesForce API Name is the same for different SalesForce objects, while the Field Label is different.
The array stored the SalesForce Field Label and API Name for SalesForce Objects Lead, Contact, and Account all at once.
Example:
| SalesForce Object | API Name | Field Label |
| Contact | Phone | Business Phone |
| Lead | Phone | Phone |
| Account | Phone | Account Phone |
Depending on the order the SalesForce call brings back the data, the SalesForceField Key drop-down will be populated with whichever one came back last.
So if you choose Contact as your WebForm SalesForceObject and Account was the last one retrieved the Drop-Down will contain Account Phone, instead of Business Phone.
The mapping will be correct, and things should work correct, but it is confusing to the user who is expecting to see Business Phone in the list, and can't figure out why Account Phone is there.
You can see this if you add a debug message in the salesforcefields.module:
function salesforcefields_salesforcewebform_fields()
{
$real_fields = salesforce_api_describeSObjects(array('Lead', 'Contact', 'Account', 'Event'));
if ($real_fields) {
foreach($real_fields as $objtype) {
// BEGIN NEW CODE
drupal_set_message(t('Object Type: ' . $objtype->name));
// END NEW CODE
foreach ($objtype->fields AS $key => $field) {
if ($field->name && $field->label) {
// BEGIN NEW CODE
druple_set_message(t('API Name: ' . $field->name . ' Field Label: ' . $field->label));
// END NEW CODE
$fields[$field->name] = $field->label;
}
}
}
}
return $fields;
}
A possible fix, is to only return the fields for the object type that the form is using (see the feature request I submitted), or to come up with someway to store the object type as well. I personally like the feature request, as why would I want to see all the fields I can't even use in the list.
Thanks
Comments
Comment #1
chriscalip commentedComment #2
chriscalip commentedI cant help out in 2.x branch see: http://drupal.org/node/1092344
Comment #3
obsidiandesign commentedFixed by #1089664: Filter the SalesForceField Key Drop-Down with only the relevant fields for the SalesForce object selected for the form by only displaying the fields specific to the object type being used.