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
Anton FlärdAnton Flärd 

SQOL - Unable to query SerialNumber field on Asset

Unable to query the field SerialNumber from table Asset. I'm administrator and all is visible/editable.
Error:
SELECT Id,Name,Account.Name,SerialNumber FROM Asset
                            ^
ERROR at Row:1:Column:29
No such column 'SerialNumber' on entity 'Asset'. 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.

Any ideas?
Best Answer chosen by Anton Flärd
Anton FlärdAnton Flärd
Thanks Prolay, found the issue.

Did this in the Execute Anonymos Window and filtered on DEBUG to see all fields on the table:
Map<String, Schema.SObjectField> fldObjMap = schema.SObjectType.Asset.fields.getMap();
List<Schema.SObjectField> fldObjMapValues = fldObjMap.values();

for(Integer i = 0; i < fldObjMapValues.size(); i++){
    System.debug(fldObjMapValues[i]);
}
I found that we are not using the standard SerialNumber but instead a custom one Serial_No__c.
 

All Answers

ProlayProlay
Use Force.com Explorer to run the query. Also please check your profile and the permission set. I ran the same query and it worked fine.
Anton FlärdAnton Flärd
Thanks Prolay, found the issue.

Did this in the Execute Anonymos Window and filtered on DEBUG to see all fields on the table:
Map<String, Schema.SObjectField> fldObjMap = schema.SObjectType.Asset.fields.getMap();
List<Schema.SObjectField> fldObjMapValues = fldObjMap.values();

for(Integer i = 0; i < fldObjMapValues.size(); i++){
    System.debug(fldObjMapValues[i]);
}
I found that we are not using the standard SerialNumber but instead a custom one Serial_No__c.
 
This was selected as the best answer