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
KD_SFGKD_SFG 

Querying ContractLineItems

Hi,

 

I have enabled ServiceContracts and ContractLineItems for my org. I am trying to write a query to get the ContractLineItems of a ServiceContract but am unable to get the Product related information in the query. Please tell me how to query for Products in the ContractLineItems object.

 

eg. [select Product from ContractLineItem] this query fails saying there is no such field I have also tried with ProductId, Product2Id etc.. The other fields are available and I am able to query them. 

 

Thanks

KD

Ritesh AswaneyRitesh Aswaney

http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_objects_contractlineitem.htm

Product2Id was once upon a time used on the Line Item Objects I reckon, to be replaced by the PricebookEntryId now

 

Product2 - < PricebookEntry > - Pricebook2 

 

So PricebookEntry is a junction object to effect a many-many relationship between Product and Pricebook.

 

So try

id pbEntryId = contractLineItem.PriceBookEntryId;

[Select Id, Name from Product2 where Id in (Select Product2Id from PricebookEntryId where ID = pbEntryId)