Skip to content

Instantly share code, notes, and snippets.

@brianbier
Created February 14, 2020 19:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brianbier/65db651af6e7a3c5ea7aac8d9e373d55 to your computer and use it in GitHub Desktop.
Save brianbier/65db651af6e7a3c5ea7aac8d9e373d55 to your computer and use it in GitHub Desktop.
New way of creating a map from recently inserted records
//After Inserting opportunities
List<Opportunity> opptys = new List<Opportunity>();
insert opptys;
// Get the IDs of the opportunities we just inserted
Map<Id, Opportunity> opptyMap = new Map<Id, Opportunity>(opptys);
//This will create a map of the opportunities
// Will allow you to do this
List<Id> opptyIds = new List<Id>(opptyMap.keySet());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment