function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Priyank SahuPriyank Sahu 

Hello guys i have to write Trigger on account insertion and updation

Using Trigger
·         On Account insertion and updation, get a Map (Account Id as Key and Account record as Value) with no duplicates.
·         Just show Map values in Debug
Best Answer chosen by Priyank Sahu
PawanKumarPawanKumar
Hi Priyank,
You no need to right any extra logic for this. You just need to use trigger context variables as below. Please let me know if it helps you.

trigger AccountTrigger on Account (after insert, after update) {
    // trigger already provides all the new Record Map 
    // which is responsible for firing the trigger.
    // Trigger.NewMap means it is a Map<Id, Account>
    System.debug(Trigger.newMap);
    
    
    //Trigger.New means it is a List<Account>
    Syste.debug(Trigger.New);
}

You can refer other trigger contextvaraibles at below link. which could be helpful for you.
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_triggers_context_variables.htm

Regards,
Pawan Kumar
 

All Answers

PawanKumarPawanKumar
Hi Priyank,
You no need to right any extra logic for this. You just need to use trigger context variables as below. Please let me know if it helps you.

trigger AccountTrigger on Account (after insert, after update) {
    // trigger already provides all the new Record Map 
    // which is responsible for firing the trigger.
    // Trigger.NewMap means it is a Map<Id, Account>
    System.debug(Trigger.newMap);
    
    
    //Trigger.New means it is a List<Account>
    Syste.debug(Trigger.New);
}

You can refer other trigger contextvaraibles at below link. which could be helpful for you.
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_triggers_context_variables.htm

Regards,
Pawan Kumar
 
This was selected as the best answer
PawanKumarPawanKumar
Please let me know if it helps you.
Priyank SahuPriyank Sahu
yes pawan thanks it is working.