Salesforce Fact #911 | Creating Location records from apex

Have you encountered this error: DML requires SObject or SObject list type: System.Location.

While creating Location records from apex, we need to specify the type as Schema.Location, else we get the above error.

Sample code:

Schema.Location lc = new Schema.Location();

lc.Name = 'Test location';

insert lc;

Reference: https://trailhead.salesforce.com/trailblazer-community/feed/0D54V00007X80VFSAZ

Comments