I have a scenario where my columns names can be of form genesis__prod__c
/docgen__prod__c
/lnd__prod__c
,etc depending upon which package is using my solution package. Here genesis
, docgen
and lnd
are different product packages using my solution.
My solution needs to fetch any of these fields (genesis__prod__c
/docgen__prod__c
/lnd__prod__c
) from their respective sObjects
in their products.
I want to construct a generic query which will omit the namespace using a wildcard and only look for prod__c
in specified sObject
. With such a solution, I wouldn't have to hardcode any namespace in my query.
For example, I don't want to form my query like this
String query = 'select Id,Name,docgen__CL_Product__c from '+ sObjectType + ' where id= \'' + appId + '\'';
List<sObject> runtimeDeterminedObject = Database.query(query+' LIMIT 1');
Here I have specifically mentioned docgen__CL_Product__c
name to be fetched from a runtime resolved sObject name sObjectType
wrt an appId
How can I form a query where I do not have to provide namespace docgen,genesis
before prod__c
. I do not want to write if-else
for each product which can utilize my package.