[SalesForce] System.QueryException: No such column

We have a development instance with a managed package TMS. That package contains a custom object TMS__Task__c.
Also we have another development instance with a managed package ABTS. TMS package is installed in ABTS development instance. Inside of ABTS package we have added a new custom field for TMS__Task__c custom object. A name of the field is ABTS__Bill_Item__c.
We've installed those 2 packages to a brand new development instance. Using development console I am trying to get a value of ABTS__Bill_Item__c field but getting an error message:

System.QueryException: No such column 'ABTS__Bill_Item__c' on entity
'TMS__Task__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.

The code in development console is:

TMS__Task__c task = [
        SELECT ABTS__Bill_Item__c 
        FROM TMS__Task__c
        LIMIT 1];

My user is set to System Administrator profile and it has an access to that ABTS__Bill_Item__c field:

enter image description here

There is a screenshot of TMS__Task__c object's fields:

enter image description here

We have the same packages (TMS and ABTS) with the same versions installed in other instances and there such SOQL query works fine. So I believe there is some type of security issue or Salesforce bug.

Best Answer

Fields need namespaces, if they are part of an installed managed package. It should be the same namespace as the object itself. If the field is custom and created within that org, it should have no namespace reference at all, since the org namespace will match.

Either this (if the field was in the managed package)

TMS__Task__c task = [
    SELECT TMS__Bill_Item__c 
    FROM TMS__Task__c
    LIMIT 1];

Or this (if the field was created by you in the managed custom object):

TMS__Task__c task = [
    SELECT Bill_Item__c 
    FROM TMS__Task__c
    LIMIT 1];

Depending on which of these scenarios fits you.

Related Topic