+ Start a Discussion

Querying ContractLineItems



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. 




Ritesh AswaneyRitesh Aswaney


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)