SOQL AggregateResult Query throws error: System.ListException: Row with null Id at index: 0
Clash Royale CLAN TAG#URR8PPP
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty margin-bottom:0;
up vote
3
down vote
favorite
Background
I have this Apex SOQL query:
myMap = new Map<Id, AggregateResult>([SELECT OpportunityLineItemId,
MIN(ScheduleDate) Starts
FROM OpportunityLineItemSchedule
WHERE OpportunityLineItemId IN :opportunityLineItemMap.keySet()
AND ScheduleDate != NULL
GROUP BY OpportunityLineItemId]);
Which throws this error:
System.ListException: Row with null Id at index: 0
Questions
- Why?
- What am I doing wrong?
- How can I fix it?
apex soql map aggregate aggregateresult
add a comment |Â
up vote
3
down vote
favorite
Background
I have this Apex SOQL query:
myMap = new Map<Id, AggregateResult>([SELECT OpportunityLineItemId,
MIN(ScheduleDate) Starts
FROM OpportunityLineItemSchedule
WHERE OpportunityLineItemId IN :opportunityLineItemMap.keySet()
AND ScheduleDate != NULL
GROUP BY OpportunityLineItemId]);
Which throws this error:
System.ListException: Row with null Id at index: 0
Questions
- Why?
- What am I doing wrong?
- How can I fix it?
apex soql map aggregate aggregateresult
add a comment |Â
up vote
3
down vote
favorite
up vote
3
down vote
favorite
Background
I have this Apex SOQL query:
myMap = new Map<Id, AggregateResult>([SELECT OpportunityLineItemId,
MIN(ScheduleDate) Starts
FROM OpportunityLineItemSchedule
WHERE OpportunityLineItemId IN :opportunityLineItemMap.keySet()
AND ScheduleDate != NULL
GROUP BY OpportunityLineItemId]);
Which throws this error:
System.ListException: Row with null Id at index: 0
Questions
- Why?
- What am I doing wrong?
- How can I fix it?
apex soql map aggregate aggregateresult
Background
I have this Apex SOQL query:
myMap = new Map<Id, AggregateResult>([SELECT OpportunityLineItemId,
MIN(ScheduleDate) Starts
FROM OpportunityLineItemSchedule
WHERE OpportunityLineItemId IN :opportunityLineItemMap.keySet()
AND ScheduleDate != NULL
GROUP BY OpportunityLineItemId]);
Which throws this error:
System.ListException: Row with null Id at index: 0
Questions
- Why?
- What am I doing wrong?
- How can I fix it?
apex soql map aggregate aggregateresult
apex soql map aggregate aggregateresult
asked 32 mins ago
Robs
1,169323
1,169323
add a comment |Â
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
3
down vote
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
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
3
down vote
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
add a comment |Â
up vote
3
down vote
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
add a comment |Â
up vote
3
down vote
up vote
3
down vote
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
As your query is currently written, a given AggregateResult
will only allow you to get three "fields":
expr0
OpportujnityLineItemId
Starts
edited 11 mins ago
answered 22 mins ago
Adrian Larsonâ¦
100k19107225
100k19107225
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsalesforce.stackexchange.com%2fquestions%2f233285%2fsoql-aggregateresult-query-throws-error-system-listexception-row-with-null-id%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password