You need to sign in to do that
Don't have an account?

Locking an Opportunity after it becomes Closed
Hi,
I am trying to find a way to lock an Opportunity and all child objects once the Opportunity is closed. I can restrict access by putting conditions on the standard buttons (to show an error message, etc), but a malicious user could bypass these. Also this does not protect detail objects, such as those from a 3rd party vendor.
I would like to force the restrictions using access rights, perhaps by setting them in a trigger as the Opportunity becomes closed. Ideally all users except Administrators should be denied access once the Opportunity has become closed.
Is this possible?
Many thanks.
- Andy
Thanks for the link Venkat.
The application itself isn't what I need but it does show that I can achieve my goals by using triggers. Something like this should do the trick:
trigger CheckOpportunityDeleteLock on Opportunity (before delete, before update) { // Perform a quick check to see if the current user and system need Opportunity locking if ( !MSO_CheckIfLocked.UserAndSystemRequireLocking() ) return; for ( Opportunity o : trigger.old ) { if ( o.isClosed ) { if ( Trigger.isUpdate ) trigger.newMap.get(o.Id).addError( 'ERROR: Cannot change an Opportunity after it has been closed.' ); else o.addError( 'ERROR: Cannot delete an Opportunity after it has been closed.' ); } } }
It's a shame the UI code in Record Lock requires S-Controls and can't (yet) be ported to Visualforce.
All Answers
Thanks for the link Venkat.
The application itself isn't what I need but it does show that I can achieve my goals by using triggers. Something like this should do the trick:
trigger CheckOpportunityDeleteLock on Opportunity (before delete, before update) { // Perform a quick check to see if the current user and system need Opportunity locking if ( !MSO_CheckIfLocked.UserAndSystemRequireLocking() ) return; for ( Opportunity o : trigger.old ) { if ( o.isClosed ) { if ( Trigger.isUpdate ) trigger.newMap.get(o.Id).addError( 'ERROR: Cannot change an Opportunity after it has been closed.' ); else o.addError( 'ERROR: Cannot delete an Opportunity after it has been closed.' ); } } }
It's a shame the UI code in Record Lock requires S-Controls and can't (yet) be ported to Visualforce.