0

I have this two validation rules

The first to express that if the profile is Profile DS or the profile has the permission set ObligatoryPermission , the field Date must be required .

and for the second it is to express that if the profile is Profile DS OR the profile has the permission set ObligatoryPermission AND the status field which is picklist is terminated , the field Details will be required .

The problem that this is not respected . Some help please

And I have a question , how can I with the validation rule make a field disabled ?

OR(($Profile.Name = "Profile DS"),($Permission.ObligatoryPermission ),
ISBLANK(Date__c )
)

AND(ISPICKVAL(Status__c , "end"), ISBLANK(Details__c ),
OR(($Profile.Name = "Profile DS"),($Permission.ObligatoryPermission )))

1 Answer 1

0

Validation rules do their job when the result of the formula is true.

With that in mind, the issue with your current validation rule is that you're OR()-ing everything together. From basic boolean algebra, if any condition in an OR() is true, the entire statement is true. If your Date__c is blank, then nothing else matters.

To determine what your validation rule should be, it helps to piece it together in plain language first. Remember that the result of your formula needs to be true for it to take effect. You're not telling Salesforce when the data is valid, you're telling them when data is invalid.

Your plain language description is close, but a simple change will help illustrate what you need to do. I'd lay out your requirement as follows:

  • If this user has the "Profile DS" profile
  • or if they have the "ObligatoryPermission" permission
  • and Date__c is blank
  • then the data is invalid

You have two things you want to OR(), and then you want to AND() it with the final condition.

From that, the formula basically is already written

AND(
    OR(
        $Profile.Name = 'Profile DS',
        $Permission.ObligitoryPermission
    ),
    ISBLANK(Date__c)
)

It's not clear what you mean by "make a field disabled", so I won't touch on that.

1
  • thank you for your help , now my validation rule work correctly , for ""make a field disabled", I mean that how can I with a Validation rule make a condition that If a field is inserted another one i can't insert in it (Should not accept any insertion / make it like disabled = true ) Mar 16, 2022 at 15:20

You must log in to answer this question.

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