You need to sign in to do that
Don't have an account?

SOQL Works in Developer Console but not in API
The following SOQL executes successfully in the Force.com developer console, but not through the API using the Partner WSDL. I am logging in as the same user to the API as I use for the developer console (same user, System Administrator profile).
SELECT OpportunityId, Id, PricebookEntryId, Product2.Name, ProductCode, Quantity, UnitPrice, Description, LastModifiedDate, IsDeleted FROM OpportunityLineItem LIMIT 5
I'm using the SOAP 31.0 api and getting the following error:
First I got an error on the Product2.Name, removed that from the SOQL and got an error on the ProductCode:
No such column 'ProductCode' on entity 'OpportunityLineItem'. 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 API worked fine with the same SOQL accessing test.salesforce.com, but not login.salesforce.com.
I looked in to field level security, but I am using the same user account/system admin profile for both developer console and api.
Appreciate any guidance you can provide.
SELECT OpportunityId, Id, PricebookEntryId, Product2.Name, ProductCode, Quantity, UnitPrice, Description, LastModifiedDate, IsDeleted FROM OpportunityLineItem LIMIT 5
I'm using the SOAP 31.0 api and getting the following error:
First I got an error on the Product2.Name, removed that from the SOQL and got an error on the ProductCode:
No such column 'ProductCode' on entity 'OpportunityLineItem'. 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 API worked fine with the same SOQL accessing test.salesforce.com, but not login.salesforce.com.
I looked in to field level security, but I am using the same user account/system admin profile for both developer console and api.
Appreciate any guidance you can provide.
You can not access the product2 fields directly from the OpportunityLineItem.you have to go through the PriceBookEntry.
Use priceBookEntry.product2.productcode
This will work.
Thanks,
Vijay
All Answers
If you are trying to create to access some custom Opportunitylineitem then please chech if there is any pricebook entried define for that.
You can not access the product2 fields directly from the OpportunityLineItem.you have to go through the PriceBookEntry.
Use priceBookEntry.product2.productcode
This will work.
Thanks,
Vijay