Trigger.newMap
This variable returns a map of ids to the new versions of sObject records.
Note:
This map is only available in before update, after insert, after update and after undelete triggers.
trigger ApexTrigger on Account(before update) {
// Only available in beforeUpdate, afterUpdate, afterInsert, afterUndelete Triggers
Map < Id, Account > nMap = new Map < Id, Account > ();
nMap = Trigger.newMap;
List < Contact > cList = [SELECT LastName FROM Contact WHERE AccountId IN: nMap.keySet()];
for (Contact c: cList) {
Account a = nMap.get(c.AccountId);
c.MailingCity = a.BillingState;
}
update cList;
}