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
Pasan   EeriyagamaPasan Eeriyagama 

No such column 'QuantityUnitOfMeasure' on entity 'Product2'

I'm trying to read Unit of Measure on Product2. But getting compile time error as below.
 
No such column 'QuantityUnitOfMeasure' on entity 'Product2'. 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.

But in Product entity field seems there.

Product standard fields

Not sure if I am using a wrong field name. In docs I couldn't find this field though. Can someone help me with reading unit of measure in product using SOQL?

Appreciate any help. Thanks.

 
Best Answer chosen by Pasan Eeriyagama
Pasan   EeriyagamaPasan Eeriyagama
Found it. It happened because of we have been using version 38 in apex class. It seems field is available for Apex query after version 39. We changed the version to latest right now (i.e. 40) and it worked fine.

All Answers

Shashikant SharmaShashikant Sharma
Hi Pasan,

Its an native fied and API name is : QuantityUnitOfMeasure

I think issue must be that you do not have read Access on the field. Go to the Field and see if you have access on field.

User-added image

Try to run a query in developer console and see if results come to verify it immediately as you check the field Access. I have checked and query works fine.


Select Id, QuantityUnitOfMeasure From Product2 Limit 1 

Thanks
Pasan   EeriyagamaPasan Eeriyagama
Found it. It happened because of we have been using version 38 in apex class. It seems field is available for Apex query after version 39. We changed the version to latest right now (i.e. 40) and it worked fine.
This was selected as the best answer