0

The Validation Rule doesn’t seem to be working. The Requirement is after the Opportunity Stage is changed to ‘Final Bid Submitted’, the user should be able to only change ‘Opportunity Stage’ field and no other field. Right now, I am being shown the error even if I don’t change anything and click ‘Save’ where Opportunity Stage is ‘Final Bid Submitted’. Please check.

IF(
    (NOT(ISNEW()) && RecordType.Name == 'BAC Overview' && ISPICKVAL(StageName, 'Final Bid Submitted')),
    IF(ISCHANGED(StageName),
        FALSE,
        TRUE
    ),
    FALSE
)
3
  • Is this the whole formula? I see an extra right parentheses at the bottom.Are you sure its complete?
    – Abhijeet
    Commented Aug 9, 2016 at 14:15
  • I have updated the formula now.Sorry missed one parenthesis
    – Samir
    Commented Aug 9, 2016 at 14:19
  • Abhijeet's solution #2 is the only no-code solution
    – cropredy
    Commented Aug 9, 2016 at 16:07

2 Answers 2

1

You won't be able to restrict this using Validation rule.To solve your problem, you have two options:

Option 1: Use a trigger to solve this issue.Below is the link you can refer to:

https://developer.salesforce.com/forums/?id=906F00000008xFXIAY

Option 2: You can create a new record type and page layout specific to this Opportunity Stage change (when Stage is updated to Final Bid Submitted, you can change the record type using workflow) and make all other fields read only on this page layout except the Stage Field.

2

You could rewrite what you have as:

AND(
    NOT(ISNEW()),
    RecordType.Name == 'BAC Overview',
    ISPICKVAL(StageName, 'Final Bid Submitted'),
    NOT(ISCHANGED(StageName))
)

To properly lock, I think what you really want is:

AND(
    RecordType.Name = 'BAC Overview',
    ISPICKVAL(PRIORVALUE(StageName), 'Final Bid Submitted'),
    NOT(ISCHANGED(StageName))
)

You want to check if the StageName value was your locked stage. Since you need PRIORVALUE, the ISNEW check is not necessary.


In order to allow empty saves, you would have to check for changes to every field you want to lock. Something like:

AND(
    // existing clauses
    OR(
        ISCHANGED(Field1__c), ISCHANGED(Field2__c) // etc
    )
)

Not very scalable, and you will quickly exceed compile size. One workaround you might be able to use is to populate a Has_Locked_Field_Changed__c checkbox via a before trigger. Then you can loop through a Field Set and see if any locked fields changed in a more scalable manner. This could be a huge performance hit, though, so make sure you only run this logic if the StageName is already the locked value.

2
  • I am still getting the same error :(
    – Samir
    Commented Aug 9, 2016 at 14:54
  • 1
    @Samir Locking all fields may not be very realistic. You can try locking a subset. If that subset is small enough, a formula may still work. Otherwise you'll need to validate using an Apex Trigger.
    – Adrian Larson
    Commented Aug 9, 2016 at 15:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .