You need to sign in to do that
Don't have an account?
J 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
(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
emp.Email__c = eMap.get(eachER.id).Work_Email__c; (Line 2 ) will be correct .