1

I am trying to change the lead owner in the trigger using a method in a class without sharing. It throws an error "You do not have level of access necessary to perform the operations...'. No error shown in debug logs. The users have read write but not transfer ownership privilege. I created a button to invoke apex code and that works fine. However I really need it work in the trigger. Is there a workaround?
When I put the same change in a future method from the trigger it works.

code

         if (newList[i].Take_Ownership__C && !oldList[i].Take_Ownership__C)
 {
           if (newList[i].OwnerId <> Label.Lead_Default_Owner)
            {
                newList[i].Take_Ownership__C.addError('Not allowed to change owner.');
            }
            else {
                        newList[i].OwnerId= UserInfo.getuserId();
                    system.debug('*** new owner' +newList[i].OwnerId);/                     
                            newList[i].Take_Ownership__C = false;
            }
       }
3
  • Can you share your code please?
    – Girbot
    Sep 25, 2014 at 6:07
  • @addy any movement on this, just running into this myself ... Dec 4, 2014 at 19:47
  • No. I am just using the future method.
    – addy
    Dec 11, 2014 at 21:54

0

You must log in to answer this question.

Browse other questions tagged .