Find your content:

Search form

You are here

Issues while cloning Attachment and changing owner through apex

 
Share

I have System Admin profile and before I did any change to code all things on the page are working fine, in clone code I did changes as I have to set attachment owner to current owner which is throwing the error if cloning oppy owner is inactive:

attachmentList.deepClone();
for(Attachment a : attachmentList){
  a.parentId = newOppy.Id;
  // I added following line then removed due to it is not working 
  // and throwing following error 
  a.ownerId = newOppy.OwnerId; 
}

Insufficient Privileges

You do not have the level of access necessary to perform the operation you requested. Please contact the owner of the record or your administrator if access is necessary.

Even after removed added line I am facing same error, not getting why this happening :( My question is :

  1. Why I am facing this error?
  2. How to change Attachment Owner if previous owner is now inactive?

Thanks in advance.


Attribution to: Bharat
This content is remixed from stackoverflow or stackexchange. Please visit https://salesforce.stackexchange.com/questions/31501

My Block Status

My Block Content