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
J Raj 3J Raj 3 

Need help: To read values from the Map in the for loop

My Code below, please advise which one is correct for bulk process update

(NOTE: Work_Email__c was formula field from the other object , so I need to update the Email__c field (Data type is Email)
// I would like keep the query out side because there may be high volume...please advise best coding design

Map<Id, Emp__c> eMap = new Map<Id, Emp__c>([SELECT Id, Email__c, Work_Email__c FROM Emp__c WHERE ID IN: XYZ);                    
for( Empl__c eachER : eMap.values() ){
    Emp__c emp = new Employment__c(id = eachER.id);
    emp.Email__c = eMap.get(emp.id).Work_Email__c;            //  Line 1 of code is Correct ?
    emp.Email__c = eMap.get(eachER.id).Work_Email__c;      //  Line 2 of code is Correct  ?


Thanks in advance
JR
Ravi Kiran 143Ravi Kiran 143
Hi , 
   emp.Email__c = eMap.get(eachER.id).Work_Email__c;  (Line 2 ) will be correct .