Empty Key Id In The Wild
I have only encountered the empty key Id in one circumstance. It represented the "All"
List View in a peculiar circumstance I discovered a while back.
Mocking Your Own Dummy Id Values
In my experience, only the key prefix and length of the
Id matter. Because of this, I can use the following logic to generate dummy
Id values. Here is a simplified example of how I create dummy values in my SObjectFactory test utility.
public class DummyIdProvider
final String prefix;
public DummyIdProvider(SObjectType sObjectType)
prefix = sObjectType.getDescribe().getKeyPrefix();
counter = 0;
public Object getValue()
return prefix + String.valueOf(counter++).leftPad(15).replace(' ', '0');
Id values generated from this structure, I can easily mock
trigger.oldMap, for instance.
final Integer recordCount = 10;
List<Contact> newRecords = SObjectFactory.create(
Contact.ObjectType, recordCount, Contact.Id,
Map<Id, Contact> oldMap = new Map<Id, SObject>(newRecords.clone(/*preserveId*/ true));
I'm not sure what other circumstances necessitate dummy
Id values. Perhaps there are some edge cases where the other components of an
Id matter. See What are Salesforce ID's composed of? for more detail, though @KeithC I'm sure you've read it and voted for it already. You still can't update or query for records with a dummy
Id, so I have a hard time believing the pod identifier is relevant.