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
Tom TavernierTom Tavernier 

SOQL left outer join opportunitylineitems to opportunitylineitemschedule

Trying to query for all opportunity product line dates and child schedule dates :
Any idea why following query does not work ?
"select servicedate, (select scheduledate FROM opportunitylineitemschedule) from opportunitylineitems limit 20"
(ERROR at Row:1:Column:81 sObject type 'opportunitylineitems' is not supported.)
It does work from opportunity to opportunitylineitem
"select closedate, (select servicedate FROM opportunitylineitems) from opportunity limit 20"
Best Answer chosen by Tom Tavernier
Balaji BondarBalaji Bondar
Hi Tom,
Try below query:
Select Id, (Select Id, ScheduleDate From OpportunityLineItemSchedules) From OpportunityLineItem
Important :
If this is what you were looking for then please mark it as a "SOLUTION" or You can Click on the "Like" Button if this was beneficial for you.

All Answers

Balaji BondarBalaji Bondar
Hi Tom,
Try below query:
Select Id, (Select Id, ScheduleDate From OpportunityLineItemSchedules) From OpportunityLineItem
Important :
If this is what you were looking for then please mark it as a "SOLUTION" or You can Click on the "Like" Button if this was beneficial for you.
This was selected as the best answer
Tom TavernierTom Tavernier
Hi Balaji,

Thanks for your  reply ! Your query works fine, even without querying on the Id fields.
Next to my typo on the "opportunitylineitemscheduleS" object (did not have the trailing "S"), it also showed me something confusing :
to query on the schedule lines, it looks like the object name is different when querying in a parent query versus querying in a sub-query :

Works fine : select closedate, (select servicedate FROM opportunitylineitemS) from opportunity limit 20 (sub-query)

Gives error : select servicedate FROM opportunitylineitemS limit 20 (parent query)
Works fine : select servicedate FROM opportunitylineitem limit 20 (parent query)

But anyways, thanks, you brought back my concentration :-)

See you, Tom