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

Clone method working i on one instance and not working on other instance
Hello there,
I have encountered a strange issue which is not allowing to complete my study about sObject clone method. Following is my code which is working fine on one of my instance and giving system limit exception of Heap size while executing. Please, note that I am executing this code in Anonymous window
Thanks in advance.
I have encountered a strange issue which is not allowing to complete my study about sObject clone method. Following is my code which is working fine on one of my instance and giving system limit exception of Heap size while executing. Please, note that I am executing this code in Anonymous window
List<Attachment> lstAttachments = new List<Attachment>(); Attachment clonedAttachment; for( Attachment attachment : [SELECT SystemModstamp, ParentId, OwnerId, Name, LastModifiedDate, LastModifiedById, IsPrivate, IsDeleted, Id, Description, CreatedDate, CreatedById, ContentType, BodyLength, Body FROM Attachment WHERE ParentId = '003A000001zbugAIAQ' LIMIT 1] ) { clonedAttachment = attachment.clone(false,false); clonedAttachment.ParentId = '006A000000ZGmbd'; lstAttachments.add(clonedAttachment); } insert lstAttachments;
Thanks in advance.
Also would be helpful if you show the error you are getting.
wil,
you are getting heap size error because of attachment that you want to clone
Please try to clone the attachment of less size, so total size of both attachment(Original and clone) not cross the heap size limit.
Thanks
Arpit