I have 3 lookup fields (Approver1,Approver2,Approver3). I need to write validation rule to maintain the Approvers in consecutive order.

Please check these Scenarios:

"Its Like previous value should be Filled"

For example:

Approver2-not filled 
Approver3- while filling the value 

I need to throw validation error.Why because Approver2 isnot filled. (While filling Approver 3, I need to fill approver 1 and 2(previuos values))

Scenario 2:

I filled Approver 2 ,Approver1 isnot filled

  Approver1-Not filled
  Approver2- while filling the value

Need to throw validation Error

I have tried below validation rule. It's not working


 AND (NOT(ISBLANK(Approver_1__c)),

 AND (NOT(ISBLANK(Approver_1__c)),

For example in this Situation:

Approver 1 & 2 already filled no need to thow error(while filling appover 3)


 Approver2- filled
 Approver3-while filling this field 


Approver2- filled

and one more if user filled "Approver 3" and not filled "Approver 4" -then no need to throw error.

  • All the approve-r are editing same Field ?
    Jul 25 '18 at 11:59

I don't think trying to handle this with a single validation rule is appropriate here.

If someone is running into an error condition, and you want them to fix it themselves, you really do need to give specific error messages and at specific locations (and even then, some users will still be unable or unwilling to fix the issue).

An error message like "approvers not filled out in order" tells your users that there is a problem, but not where the problem is.

I'd recommend breaking this out into multiple validation rules so you can provide specific errors and at specific locations. Doing this should also have the effect of simplifying your validation rule(s).

Further, I might suggest using a different perspective. Instead of trying to detect if all previous approver fields are filled before filling the current approver field, try to detect when a subsequent approver is being set but the current approver is not.

An example

On your Approver_1__c field


The error message you could give here would be specific

Approver 1 needs to be filled out before subsequent approvers can be filled out

The error location can be on your Approver_1__c field.

The reason why my example includes OR(ISBLANK(Approver_1__c), false) is so that you can copy-paste this to additional validation rules. You'll just need to shuffle the ISBLANK(<field>) from one OR to another OR (adding/removing the NOT() as appropriate)

As an added benefit, this approach should ensure that, if multiple previous approver fields are blank, you will display errors on each one of the previous fields that are missing a value. Fixing one error only to run into another error is a pet peeve of mine.

  • I am already near to validation rule Limit (100).So I cant add one more now!!!.Thats why I tried to handle in single validation rule Jul 25 '18 at 16:46
  • @SFDC_Learner That would be an example of good information to include in your question. Are all of those validation rules active (the limit only applies to active rules)? Can any of the existing validation rules be consolidated or deactivated?
    – Derek F
    Jul 25 '18 at 17:04
  • yes.They are all active . Jul 27 '18 at 10:09

IF(NOT(IsBlank(Approver_3__c)) , OR((IsBlank(Approver_2__c)),(IsBlank(Approver_1__c))),

IF(NOT(IsBlank(Approver_2__c)) , (IsBlank(Approver_1__c)),

IF((IsBlank(Approver_1__c)) , false, true ) ) )

Try this through validation rule.

  • 2
    This answer would be better if you were to explain what was wrong with the original validation rule, and why this validation rule should work. Without that, this answer amounts to a "code dump", which tend to be low-quality answers and generate a lot of "that didn't work" and "try this instead" back-and-forth in the comments (which is not helpful for other people with similar problems looking at this answer)
    – Derek F
    Jul 25 '18 at 13:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.