function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Jarosław Kołodziejczyk 12Jarosław Kołodziejczyk 12 

Assigning attachment on lead conversion to opportunity.

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.
Best Answer chosen by Jarosław Kołodziejczyk 12
Srinivas SSrinivas S
  1. In general we see 15 digit id (0013600000LjlAi) through userinterface.
  2. When accessing through a program (API) it will fetch 18 digit id (0013600000LjlAiAAJ)
  3. I am not seeing a delete statement, please include delete stmt.
------------
Thanks,
Srinivas
- Please mark as solution if your problem is resolved.