Blog

Main » 2018 » January » 16

Set past date:

Date closeDate = Date.today().addDays(-7);

Quickest way to get a list of IDs from a list of sObjects:

List<opportunity> opptys = new List <opportunity>();
Map <id, opportunity> opptyMap = new Map <id, opportunity>(opptys);
List <id> opptyIds = new List <id>(opptyMap.keySet());

Get the most recent record using SOQL

[SELECT Id FROM sObject ORDER BY CreatedDate DESC LIMIT 1];