You need to sign in to do that
Don't have an account?

How to pass Opportunity id in SOQL for below trigger.
Hi,
I need help in passing opportunity id in the below soql query for Trigger. Am using this trigger to copy attachments from opportunity to Quote whenever the quote is created from opportunity. I have hard coded the record id and i need to how to get the record id in the query.
trigger CloneAtt on Quote (after insert) {
Attachment[] attList = [SELECT id, name, body, parentid
FROM Attachment
WHERE ParentId = '0060K00000Ra3Ei'];
Attachment[] insertAttList = new Attachment[]{};
for(Attachment a: attList){
Attachment att = new Attachment(name = a.name, body = a.body, parentid = Trigger.new[0].id);
insertAttList.add(att);
}
if(insertAttList.size() > 0){
insert insertAttList;
}
}
I need help in passing opportunity id in the below soql query for Trigger. Am using this trigger to copy attachments from opportunity to Quote whenever the quote is created from opportunity. I have hard coded the record id and i need to how to get the record id in the query.
trigger CloneAtt on Quote (after insert) {
Attachment[] attList = [SELECT id, name, body, parentid
FROM Attachment
WHERE ParentId = '0060K00000Ra3Ei'];
Attachment[] insertAttList = new Attachment[]{};
for(Attachment a: attList){
Attachment att = new Attachment(name = a.name, body = a.body, parentid = Trigger.new[0].id);
insertAttList.add(att);
}
if(insertAttList.size() > 0){
insert insertAttList;
}
}
Try with the below code and it will work.
When writing a trigger, always write a bulk code.