You need to sign in to do that
Don't have an account?
How to create test data to test a closed opportunity which has a validation rule that prevents update?
With the validation rule active, getting validation error saying cannot update closed opportunity, while trying to insert the opportunity record. Any pointers to solve this?
Please modify the validation rule as like below and try will fix the error.
Thanks!!
All Answers
Just insert the opportunity test data with status as closed.
If this helps, please mark it as best answer.
Thanks!!
Run your test class in system admin user mode, you will not get any error.
If this hepls, Please mark it as best answer.
Thanks!!
SELECT Id, Name FROM user WHERE profile.Name = 'System Administrator' AND IsActive = true LIMIT 1
But, still it didn't work. Same validation error is being thrown...
Please modify the validation rule as like below and try will fix the error.
Thanks!!
AND( OR($Profile.Name <> 'System Administrator', $Profile.Name <> 'Some Other Profile'), ISPICKVAL(PRIORVALUE(StageName), 'Closed Won') )
AND( AND($Profile.Name <> 'System Administrator',
$Profile.Name <> 'Some Other Profile'),
Text(PRIORVALUE(StageName)) = 'Closed Won' )
Yes, above formula is good.
Thanks,
Ankaiah