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
jagdish nikam 9jagdish nikam 9 


Hi Team,

Could you please check below link?

In this link they used in before insert event ( in a code where they used best practise). I read somewhere that if we use trigger.newmap.keyset in before insert then it will give null id's.

Could you please clarify my doubt?
Rahul KumarRahul Kumar (Salesforce Developers) 
Hi Jagdish,
  • In the trigger, if you try to call trigger.newMap.keySet() on update event or after inserting it will return Id of records which are going to process.
  • In the trigger, if you try to call trigger.newMap.keySet() on before insert then it will return null.
I hope it will be helpful.

Best Regards
Sree SalesforceSree Salesforce
Before insert means  :-  Record was not inserted in salesforce . So We dont have Salesforce id.
User-added image
if ypou are not getting please let us know