You need to sign in to do that
Don't have an account?

fields in Contact object in Trigger are all null?
I'm trying to write my first trigger (on Contacts), and I'm finding that the Trigger.new collection of Contacts seem to only hold contact.Id, but all other fields of the contacts are null.
Here's the code, and it asserts at c.Name != null. All the other sample code I've looked at seem to reference fields of the objects in Trigger.new without any problems. What am I doing wrong?
trigger ContactTrigger on Contact (after insert, after update) {
for (Contact c:Trigger.new) {
system.assert(c != null);
system.assert(c.Id != null);
system.assert(c.Name != null);
}
}
Name is a read-only compound field, and so isn't resolved until after a DB roundtrip, other regular fields on contact should be fine.

I'm testing this on an update of an existing record. I've also tried several other fields of existing records, like Account and Household (a custom field). They all come back null. No luck!
only data fields that are directly part of the object are populated, fields from related objects (accessible via relationships, like account) are not, if you need the related data you need to query for it, using the FK ids (e,g. accountId)