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
TenaTena 

RunAs to update locked Opportunity

I have an object that is linked to an Opportunity.  When this object is updated it needs to update the opportunity.  However, in some cases the opportunity is in an approval process and this causes the error "; first error: ENTITY_IS_LOCKED, the entity is locked for editing: []".  Can I use the RunAs to make the class run under an administrator because even though this opp is locked it needs to be updated.  I only see runas used in Test Classes.

 

Thanks,

 

Tena

TenaTena

According to what I read about system mode is that it doesn't take the user into consideration when running the code.  I find this odd becasue when an opportunity is locked and a user exectues a trigger that I wrote there is an error of  "ENTITY_IS_LOCKED".   However, if I do the exact same thing as an administrator I don't get the error. Does this mean then that the opportunity being locked has nothing to do with this issue?

 

Thanks,

 

Tena