Last active
January 17, 2024 20:48
-
-
Save lukethacoder/7ec68c8cae6319a84ba03aa1869f1f3b to your computer and use it in GitHub Desktop.
APEX: Get a Set<Id> of Id's from a List<SObject> of Objects
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Query list of Accounts | |
List<Account> accounts = [ | |
SELECT | |
Id, Name | |
FROM | |
Account | |
]; | |
// get Set of Ids of the Object | |
Set<Id> ids = new Set<Id>(new Map<Id, Account>(accounts).keySet()); | |
System.debug('Account Ids as Set<Id>: ' + ids); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment