Skip to main content
added 161 characters in body
Source Link
Adrian Larson
  • 151.3k
  • 38
  • 247
  • 431

You need to alias some field to Id in order for the Map<Id, SObject>(List<SObject>) constructor to work.

SELECT
    OpportunityLineItemId Id, 
    MIN(ScheduleDate) Starts
FROM OpportunityLineItemSchedule 
WHERE ...
GROUP BY OpportunityLineItemId

As your query is currently written, a given AggregateResult will only allow you to get three "fields":

  • expr0
  • OpportujnityLineItemId
  • Starts

You need to alias some field to Id in order for the Map<Id, SObject>(List<SObject>) constructor to work.

SELECT
    OpportunityLineItemId Id, 
    MIN(ScheduleDate) Starts
FROM OpportunityLineItemSchedule 
WHERE ...
GROUP BY OpportunityLineItemId

You need to alias some field to Id in order for the Map<Id, SObject>(List<SObject>) constructor to work.

SELECT
    OpportunityLineItemId Id, 
    MIN(ScheduleDate) Starts
FROM OpportunityLineItemSchedule 
WHERE ...
GROUP BY OpportunityLineItemId

As your query is currently written, a given AggregateResult will only allow you to get three "fields":

  • expr0
  • OpportujnityLineItemId
  • Starts
Source Link
Adrian Larson
  • 151.3k
  • 38
  • 247
  • 431

You need to alias some field to Id in order for the Map<Id, SObject>(List<SObject>) constructor to work.

SELECT
    OpportunityLineItemId Id, 
    MIN(ScheduleDate) Starts
FROM OpportunityLineItemSchedule 
WHERE ...
GROUP BY OpportunityLineItemId