I have an approval process for the Opportunity object. But I want to unlock a record during this process to add a very important information that can only be obtained later and then lock the record again. I've tried this code:
Opportunity op= [Select someCustomField FROM Opportunity WHERE ID = : param.OportunidadeId];
op.someCustomField = 'Very important information not initially provided.';
Approval.unlock(op);
update op;
Approval.lock(Oportunidade);
But I received the error below:
System.DmlException: Delete failed. First exception on row 0 with id xxxxxxxxxxxxxxx; first error: INSUFFICIENT_ACCESS_OR_READONLY, insufficient access rights on object id: []
Why do I get this error? How do I fix it?