-3

I have a requirement to give access to closed own opp. to some for only 3 days after opp. is closed own at the same time some profiles like system admin must have access to edit closed opp all the time. My validation looks like this, but seems not working as expected, some help would be appreciated.

    AND(
       ISPICKVAL(PRIORVALUE(StageName),"Closed Won"),
       IsAutomationBypassed__c = false,
      OR(
       AND ( Closed_Date__c < TODAY()-3,
         NOT(OR     /*(has access of closed opp. for 3 days after its closed own.)*/ 
              ( 
              $UserRole.Name = "Head of Customer Growth",
              $UserRole.Name= "Customer Growth Rep"
          ))),
         NOT(OR(     /*  (This group has access of closed opp.all the time)*/
          $Profile.Name = "System Administrator",
          $Profile.Name = "Finance Administration",
          $Profile.Name = "Super User",
          $User.Alias = 'mmmm'
          )) )
        )
2
  • 1
    What part "is not working as expected"? Jan 26, 2022 at 20:05
  • Thank you for Down vote, when some other could understand what it meant but you could not, was there a problem in my question or your understanding? I understand people are different and its a validation rule, I do not know exactly what part is not working, as system admin were not able to edit this closed opp. Was that what you wanted to hear? You could have just asked that instead of downvoting.
    – tough
    Jan 27, 2022 at 10:19

1 Answer 1

1

Can you try using this validation rule. The main issue in your validation rule is you are using OR condition in Line 4 you should be using AND condition.

I tried the similar validation rule. Replace your roles and profiles based on your requirement.

AND(
ISPICKVAL(PRIORVALUE(StageName),"Closed Won"),
AND(
NOT(AND ( Closed_Date__c > TODAY()-3,OR
(
$UserRole.Name = 'Head of Customer Growth',
$UserRole.Name= 'COO'
)
)),
NOT(OR(
$Profile.Name = "System Administrator",
$Profile.Name = "Finance Administration"
)) )
)
2
  • Thank you @SaiPraveen for your quick reply, I am confused about the use of AND in the 3 rd line. Can you help me make sense of it? My fat mind could not get it may be.
    – tough
    Jan 26, 2022 at 12:49
  • 1
    Is this working as expected? Explanation: If user does not belongs to both the condition then it should fire the validation rule so in this scenario FLASE AND FALSE will return false so this works fine if we keep AND or OR condition. But if User belongs to role in validation rule but not the profile then this validation rule should not fire we are using AND condition because True and False will return False and validation will not fire. If you are using OR condition this validation will fire. Jan 26, 2022 at 12:59

You must log in to answer this question.

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