Timeline for Map<Object, List<SObject>> cannot be cast to Map<String, List<Account>>
Current License: CC BY-SA 3.0
16 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Jan 13, 2017 at 18:14 | comment | added | ipavlic | Let us continue this discussion in chat. | |
Jan 13, 2017 at 18:13 | history | edited | ipavlic | CC BY-SA 3.0 |
added 30 characters in body; edited title
|
Jan 13, 2017 at 18:12 | comment | added | ipavlic |
Yes, I see now, because you can implicitly cast List<sObject> to List<Account> (!) but not sObject to Account . I'll edit the question again to match the answers.
|
|
Jan 13, 2017 at 18:04 | comment | added | Adrian Larson♦ |
But it's a dramatically more complicated question when you want the map value to be SObject instead of List<SObject> .
|
|
Jan 13, 2017 at 18:04 | comment | added | ipavlic |
@AdrianLarson No, I want GroupBy , and that's what I got, thank you! I just simplified the question when asking.
|
|
Jan 13, 2017 at 17:53 | comment | added | Adrian Larson♦ |
So you want MapBy , not GroupBy ?
|
|
Jan 13, 2017 at 17:52 | history | edited | ipavlic | CC BY-SA 3.0 |
deleted 12 characters in body
|
Jan 12, 2017 at 23:03 | answer | added | Adrian Larson♦ | timeline score: 2 | |
Jan 12, 2017 at 22:43 | vote | accept | ipavlic | ||
Jan 12, 2017 at 22:33 | answer | added | sfdcfox♦ | timeline score: 5 | |
Jan 12, 2017 at 22:32 | comment | added | ipavlic | @AdrianLarson I am, yes. I'd like to group sObjects by some field other than Id. | |
Jan 12, 2017 at 22:24 | comment | added | Adrian Larson♦ |
It's very different when your key type is SObject vs List<SObject> . Where are you getting the structure from? Are you trying to write a mapping/grouping utility?
|
|
Jan 12, 2017 at 22:17 | comment | added | Ashwani | The only way is avoid this design. This is broken in Apex. You can only control this during iteration (for-loop). | |
Jan 12, 2017 at 22:09 | history | edited | Adrian Larson♦ | CC BY-SA 3.0 |
added 4 characters in body
|
Jan 12, 2017 at 22:08 | comment | added | sfdcfox♦ | The Type system is fundamentally broken. See this question where I delve further into the limitations of the current Type system. | |
Jan 12, 2017 at 22:04 | history | asked | ipavlic | CC BY-SA 3.0 |