1

I have two validation rules. I've not been able to combine the two rules into one.

One rule: Only system admin should be able to click a check box called 'new order' when an opportunity is already assigned an owner.

Second rule: Prevent users from unchecking the 'new order' checkbox if already checked true.

Here are the two separate rules that works separately that I have done:

First rule:

AND(IsNewOrder__c = TRUE,
NOT ISBLANK( AssignedTo__c ),
$Profile.Name <> 'System Administrator')

Second rule:

AND(
ISCHANGED(IsNewOrder__c),
PRIORVALUE(IsNewOrder__c) = true,
$Profile.Name <> 'System Administrator')

Any help to combine these two into one would be much appreciated.

Many thanks

1

EDIT - Updated Bottom Version - I think it's what you want.

It depends on which way you want to combine them - both or either of them.

Either can cause the rule to fire:

OR (
  AND(IsNewOrder__c = TRUE, NOT ISBLANK( AssignedTo__c ), $Profile.Name <> 'System Administrator'),
  AND( ISCHANGED(IsNewOrder__c), PRIORVALUE(IsNewOrder__c) = true, $Profile.Name <> 'System Administrator')
)

Both needed to cause the rule to fire:

AND (
  AND(IsNewOrder__c = TRUE, NOT ISBLANK( AssignedTo__c ), $Profile.Name <> 'System Administrator'),
  AND( ISCHANGED(IsNewOrder__c), PRIORVALUE(IsNewOrder__c) = true, $Profile.Name <> 'System Administrator')
)

Finally a fancier way - this way avoids writing the administrator rule twice:

AND (
  $Profile.Name <> 'System Administrator',
  ISCHANGED(IsNewOrder__c), 
  OR (
    AND (
      NOT (ISBLANK( AssignedTo__c )),
      IsNewOrder__c = TRUE
    ),
    PRIORVALUE(IsNewOrder__c) = true
  )
)
2
  • Fantastic. It worked! Thank you @ Caspar and Sahil! :-) And yes, the fancier way is preferable. Your help is much appreciated. May 18 '21 at 9:08
  • If it worked for you, you can mark as accepted ;) May 18 '21 at 9:48

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.