Hot answers tagged

3

The easiest is to create a Set<Object[]>, something like the following: Set<Object[]> alreadySeen = new Set<Object[]>(); List<Schedules__c> uniqueSchedules = new List<Schedules__c>(); for (Schedules__c schedules : SchedulesToProcess) { Object[] key = new Object[]{ schedules.Month__c, schedules.Year__c }; if (!...


2

There is no simple one-line method (as in JavaScript, where we can e.g. Array.prototype.flat), its most simple form would be: List<Contact> allContacts = new List<Contact>(); for(List<Contact> contacts: accountWithContacts.values()) { allContacts.addAll(contacts); }


2

You can use JSON2Apex to generate the relevant code for parsing. The ideal solution for parsing is to use classes, which can then be deserialized to directly. I converted the code from there to a simpler implicit parser (because of an apparent bug in JSON2Apex), which gives us: // // Generated by JSON2Apex http://json2apex.herokuapp.com/ // public class ...


1

The Map<Id, sObject> var = new Map<Id, sObject>(listOfsObject); (where sObject is any type of object, like Account or CustomObject__c) is semantically equal to: Map<Id, sObject> var = new Map<Id, sObject>(); for(sObject record: listOfsObject) { var.put(record.Id, record); } Note that you're not casting (explicit conversion from one ...


Only top voted, non community-wiki answers of a minimum length are eligible