We are developing a managed package that contains a custom object and a REST API to do CRUD operation on that object. We are not using standard salesforce REST API for valid business reasons.
In this REST API we allow user to set value of field on custom object that are part of managed package as well unmanaged field that they may create after package installation. Field that are part of package will be qualified by namespace prefix.
We are facing a issue that may be a platform bug. Here is situation.
- Let's assume we have a field with API name
FirstName__c
and namespace isabc
so fully qualified field name will beabc__FirstName__c
. - After package installation customer creates another field with same API name(
FirstName__c
) which is perfectly valid as namespace prefix make them unique. - Through our API user can pass a map of name-value pair, where key is API name of field and value is field value.
- Within API we use this map to set value of field by using
SObject.put(fieldname, value)
method. FieldName is string and value is Object type casted dynamically by checking type of field using describe call. - Problem that we are facing is that if user pass field name as
FirstName__c
,sObject.put()
method sets value of packaged field i.e.abc_FirstName__c
notFirstName__c