• J Raj 3
  • NEWBIE
  • 10 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 0
    Replies
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
Hi Dev Guru's,

I've saved couple of pdf documents in the SF Document Object >> Shared Documents folder and would like to attach to sendEmail method. The below class code working but need help with Test Class code. 

<And please advise if below code is not efficient>

        List<Messaging.Emailfileattachment> xxx  = new List<Messaging.Emailfileattachment>();
        List<Messaging.Emailfileattachment> yyy = new List<Messaging.Emailfileattachment>();

                  for ( Document doc : [SELECT Name, Body, BodyLength, ContentType FROM Document
                                      WHERE (Name =: AAA OR Name =: BBB ) LIMIT 2] ) {
                    if(doc.Name == 'AAA' ){                        
                            Messaging.EmailFileAttachment efa = new Messaging.EmailFileAttachment();
                                efa.setFileName(doc.Name);
                                efa.setBody(doc.Body);
                                efa.setContentType(doc.ContentType);
                            xxx.add(efa);
                    } else if(doc.Name == 'BBB' ){                        
                            Messaging.EmailFileAttachment efa = new Messaging.EmailFileAttachment();
                                efa.setFileName(doc.Name);
                                efa.setBody(doc.Body);
                                efa.setContentType(doc.ContentType);
                            yyy.add(efa);
                    }
                }
                
Thank You
JR