Article #000001026
Summary
Historically, Salesforce does not identify a field when referenced in code as part of a managed namespace package. So, when we execute a query to retrieve certain fields for some records, we just add our managed fields to the query and execute to retrieve the data. This is when the trouble begins. When the user creates a custom field on the object with the same name, this causes two fields with the same name on the object, the only distinction being a namespace that is unique to ISVs (our package) and applies it to our packaged field only. Since the platform wasn't distinguishing the two fields based on a namespace and it recognizes the two fields with the same name and when we execute our query for data retrieval, it causes an error that is a hard limit for the platform, such that no field can be duplicated in a query.
Question
Why do I get a duplicate field selected error?
Duplicate field selected advpm__xxxxxxxx__c
Resolution
Field API names can't be duplicated because Salesforce doesn't include the field namespace when evaluating dynamic query logic.
Workaround
These field names have to be re-named in order to prevent errors.