I'm working on managed package and I have to insert Attachment record from my apex code.
The code is pretty simple, that's just create and insert Attachment, something like that:
Attachment attachment = new Attachment (Body = Blob.valueOf(bodyText), ContentType = 'text/plain', ParentId = parentId, Name = 'Name'); insert attachment;
this code is exposed to customer via
global class. These I can run same test code on my developer org and on org where my package is installed which will invoke my global class.
The code works fine on development org. But when I tried to use this code in another org where my managed package is installed I got the following error:
System.SObjectException: Field is not writeable: Attachment.ParentId
On both environments I run test code from System Admin user.
I see that
Attachment.ParentId field was not included into Package Dependencies although this field is used in few apex classes of my package.
Can someone tell me what I missed?