I'm trying to clone an attachment on an opportunity to a custom case object via a trigger. My code is creating the case but not cloning the attachment. Is there anything I can do to get this to work?
trigger RDAssessmentCreation on Opportunity (after insert, after update) {
list<PlatformCase__c> lstPC = new List<PlatformCase__c>();
list<map<Date,PlatformCase__c>> lstmapPC = new list<map<Date,PlatformCase__c>>();
list<Opportunity> lstOpp = [Select id, Accountid,Filing_Deadline__c, Projected_Delivery_Date__c, CloseDate, StageName, Generate_Projects__c, RecordTypeId,(Select Id, ProductID__c,Jurisdiction__c,Quantity,ServiceDate From Opportunitylineitems) From Opportunity
];
for(opportunity opp : trigger.new){
if(opp.StageName =='3 - Assessment Request' && opp.RecordTypeId == '012M00000004qsD') {
lstPC.add(new PlatformCase__c(Opportunity__c = opp.Id,
Subject__c = 'Test R&D Case',
Status__c = 'New',
Category__c = 'Data Support',
Description__c = 'Test Add Case Attachment'));
list<Attachment> lstAttachment = [SELECT id FROM Attachment WHERE parentID IN :lstOpp];
Attachment newAtt = new Attachment(ParentId = opp.id);
}
}
insert lstPC;
}