Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class TempDeleteOpplgtwithnoOpp {
- Public void getalltodeleterecords()
- {
- //*Map<ID, Opportunity> Oppmap = new map<id, Opportunity>([SELECT ID, NAME FROM Opportunity LIMIT 10]);
- Set<id> oppidlist = new Set<id>();
- for(Opportunity opp : [SELECT ID FROM Opportunity])
- {
- oppidlist.add(opp.id);
- }
- string OpplgtDelNoOppStringFinal =
- 'ID'+','+'Name'+','+'CreatedDate'+','+'LastModifiedDate'+','+'Opportunity_Lgt_Name'+','+' Opportunity_id_txt __c'+'n';
- List<id> opplgttoDelIdSet = new List<ID>();
- for(Opportunity_LGT__C opplgt : [SELECT ID, Name, CreatedDate, LastModifiedDate, Account_Code__c,
- Opportunity_Lgt_Name__c, Opportunity_id_txt __c FROM Opportunity_LGT__C] )
- {
- IF (!Oppidlist.contains(opplgt.id))
- {
- opplgttoDelIdSet.add(opplgt.id);
- String OpplgtDelNoOppString = opplgt.id +','+opplgt.name+','+opplgt.CreatedDate+','+opplgt.LastModifiedDate+','+opplgt.Opportunity_Lgt_Name__c+','+opplgt.Opportunity_Record_Id__c +'n';
- OpplgtDelNoOppStringFinal = OpplgtDelNoOppStringFinal+ OpplgtDelNoOppString ;
- }
- }
- system.debug('Opplgtlist.size: ' + Oppidlist.size());
- system.debug('opplgttoDelIdSet.size:' + opplgttoDelIdSet.size());
- Messaging.EmailFileAttachment DelOLNoOpp = new Messaging.EmailFileAttachment();
- Blob DelOLNoOppcsvBlob = Blob.valueof(OpplgtDelNoOppStringFinal);
- String DelOLNoOppcsvname = 'DelOLNoOppOL.csv';
- DelOLNoOpp.setFileName(DelOLNoOppcsvname);
- DelOLNoOpp.setBody(DelOLNoOppcsvBlob);
- Messaging.singleEmailMessage ademail = new Messaging.singleEmailMessage();
- List<String> toAddress = new List<String>{'raghavendra.shettigar@inventivHealth.com'};
- ademail.setSubject('OppLightDeleteFiles');
- ademail.setToAddresses(toAddress);
- ademail.setPlainTextBody('Opportunity Light Delete');
- ademail.setFileAttachments( new messaging.emailFileAttachment[]{DelOLNoOpp });
- Messaging.SendEmailResult[] r = Messaging.sendEmail(new Messaging.singleEmailMessage[]{ademail});
- set<Id> accIds=new set<Id>();
- for(Opportunity opp:[Select AccountId from Opportunity where ID in :setoppIds]){
- accIds.add(opp.AccountId);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement