• Jarosław Kołodziejczyk 12
  • NEWBIE
  • 10 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 0
    Replies
Hey,

 I have a problem with apex code thats supposed to delete attachment added to account after lead conversion, and then add the copy of this attachment to opportunity.

But when i convert my lead, nothing happens, i checked the Attachment.ParentID with system debug and i found something strange.
 The normal id of account is 0013600000LjlAi, but when in the debug its 0013600000LjlAiAAJ, do you know why that would happen?

Here is part of code responsible for getting parendId:

________
trigger Update_Attachment_Parent on Attachment (after insert, after update) {
//Create a List to store the Ids of Attachments to be deleted
List<Id> forDeletionIds = new List<Id>();
for (Attachment a : trigger.new){
//Check to see if the Attachment has an Account as the Parent Record
    
if(a.ParentId.getSobjectType() == Account.SobjectType){
    
//Select the Primary Opportunity from the Account
Account parent = [SELECT Primary_Opportunity__c FROM Account WHERE ID = :a.ParentId]; 
    
System.debug('The parentID is: ' + a.ParentId);
________


Side note: Person Accounts are enabled for our org and every converted account is a person account.