function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Hung Tran LDHung Tran LD 

Lookup field failed to be queried because Salesforce is referencing wrong object with the same (Even with namespace)

The setup:
1. Org contains a custom object called objectX__c
2. A packaged app also contains a custom object called objectX__c but Salesforce automatically added a namespace there i.e. `someapp__.objectX__c`
3. The org has a custom lookup field on the account that looks to objectX__c, i.e. `Account.lookup_objectX__c`
4. The package app tries to run a query as `select id, lookup_objectX__r.some_field__c from Account`
5. This error occurs 

No such column 'some_field__c' on entity 'someapp__objectX__c'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names.

This error should not be happening because the lookup field is setup correctly to look at the non-namespaced object, but Salesforce is looking at the namespaced object which then fail.

SANDEEP CHITTINENISANDEEP CHITTINENI
http://workbench.developerforce.com (http://workbench.developerforce.com" target="_blank)
once go to the link and log in with your Salesforce credentials. Use SOQL Query to get an exact SQOL statement.

Thank you,
Sandeep Chittineni.
 
Shweta AlwaniShweta Alwani
Hi,

Please check :
1. User have permision to field : some_field__c
2. if you are using correct relationship name for object someapp__objectX__c

Thanks
Hung Tran LDHung Tran LD
Permissions are correctly setup. Relaship to the object are set up correct. This is reproducible. We found that within Managed App, Salesforce always default to look at the managed app object first and does not see the subscriber object even if the reference field was set up correctly. We had to migrate the managed app's data to a new renamed object and it worked.