+ Start a Discussion
Sukhdeep SinghSukhdeep Singh 

Not able to query on standard Asset field 'ProductCode' . Please suggest

List<Asset> lst=  [select Id, ProductCode, Product_Family1__c, Product_Family__c from Asset WHERE AccountId = '0015000000IBGof' AND ( (NOT IB_Status__c Like '%eval%') OR (NOT IB_Status__c Like '%Under Right of Return%') OR (NOT IB_Status__c Like '%Sold - Demo%') OR (NOT IB_Status__c Like '%WRITTEN OFF%') ) AND Product_Family__c != 'Whitewater'];

I am getting below error
No such column 'ProductCode' 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.

Also I need to use group by (Product_Family1__c, Product_Family__c) this query But getting error
Akhilesh DahatAkhilesh Dahat

Your Error Define your answer.Try to use ProductCode__c. Also try to execute below query on https://workbench.developerforce.com/query.php.

List<Asset> lst=  [select Id, ProductCode__c, Product_Family1__c, Product_Family__c from Asset WHERE AccountId = '0015000000IBGof' AND ( (NOT IB_Status__c Like '%eval%') OR (NOT IB_Status__c Like '%Under Right of Return%') OR (NOT IB_Status__c Like '%Sold - Demo%') OR (NOT IB_Status__c Like '%WRITTEN OFF%') ) AND Product_Family__c != 'Whitewater'];

KaranrajKaranraj
Try the below query 
List<Asset> lst=  [select Id, Product2.ProductCode, Product_Family1__c, Product_Family__c from Asset WHERE AccountId = '0015000000IBGof' AND ( (NOT IB_Status__c Like '%eval%') OR (NOT IB_Status__c Like '%Under Right of Return%') OR (NOT IB_Status__c Like '%Sold - Demo%') OR (NOT IB_Status__c Like '%WRITTEN OFF%') ) AND Product_Family__c != 'Whitewater'];

Check this link to user Group by in SOQL query http://www.salesforce.com/us/developer/docs/soql_sosl/Content/sforce_api_calls_soql_select_groupby_rollup.htm
Sukhdeep SinghSukhdeep Singh
Hi Karanraj,

Thanks for your reply, 
Product2.ProductCode  is giving me product id. I also need product name. But when I tried Product2.Name, It did`t work.
Also I tried GROUP BY ROLLUP(Product_Family__c) But it gives me error.
Could you please elaborate on it also.
 
SF AdminSF Admin

chck this:

http://www.salesforce.com/us/developer/docs/soql_sosl/Content/sforce_api_calls_soql_select_groupby_rollup.htm

regards
MOhd

KaranrajKaranraj
@Sukhdeep - Did you try running that query in developer console to see the result? Its gives me proper value, when I run that query in the developer console. Just try the below query in the developer console to see the result
 
select id,Name,product2.productcode,Product2.Name from asset


User-added image
Sukhdeep SinghSukhdeep Singh
Thanks Karanraj, 
Its working for me.

 
Bob HatcherBob Hatcher
Just to follow up on this old thread, a colleague ran into this problem and determined that API Version matters - in older API versions the stagename is not visible in DML. For example, we have two classes in the same org, one runs on 39 and one on 41. In 39, the following does not compile:
List <Asset>  assetList = [select id, name, product2.id, product2.family, SBQQ__CombineKey__c, createdDate,SBQQ__OptionLevel__c   from asset];
but it does in 41.