Stuck with an issue related to Dynamic SOQL queries in Managed package.
As an example in our package, we have a object and field named as sf_com_bh__Application__c
and sf_com_bh__Application_method__c
respectively.
Our application has a page which display the records from sf_com_bh__Application_method__c
based predefined filters. Admin from subscriber org can create their own custom fields and add it to the filter via some configuration.
Things works fine until subscriber's create a custom field with same name as from the package, lets say Application_method__c
.
Basic query would then look like:
SELECT Id FROM sf_com_bh__Application__c WHERE
(sf_com_bh__Application_method__c LIKE :keyword OR
Application_method__c LIKE :keyword)
LIMIT 100
Tried to set the context, now problem is that the above query totally neglects the custom field created by subscriber in where clause.
Also unfortunately our customers cannot change the field api name as its being used in their integration.
Please share some thoughts or workaround, if any.
Following links mentions that in such scenario query it will give preference to subscriber's field instead of from the managed package, in today's date it is not correct. Has Salesforce reversed the implementation such that now all fields in dynamic soql refer to the packaged field; if subscriber has the field with same name?
- Idea:
Support Dynamic SOQL "No Shadowing" Option
- Related question:
Dynamic SOQL Queries and Managed Namespaces
).