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;


Our Recent Blog

Share This Post