0

I have a validation rule that doesn't seem to work. I think the issue is the Stagename field. I've tried the Stagename values with and without spaces. When I have a record that should meet the criteria, no error message is displayed. The rule should work like this:

If Stage name is equal to Closed – Won or Closed-No Sale, the Opportunity_outcome field is not blank,the Primary_Reason_Won_or_Lost__c field is blank, and the user does not have the By Pass Opportunity Validation Rules permission then the rule fires.

I'm not sure what I'm doing wrong. Please see the rule below.

AND( 
( 
ISPICKVAL ( StageName , 'Closed - Won' ) || 
ISPICKVAL ( StageName , 'Closed - No Sale' )), 
( 
NOT(ISPICKVAL (Opportunity_Outcome__c, '' )) && 
ISPICKVAL( Primary_Reason_Won_or_Lost__c,'' )), 
NOT( $User.By_Pass_Opportunity_Validation_Rules__c ) 
)
4
  • Can you expand on what you mean by "doesn't seem to work". Is there an error? If not, can you explain what the rule is trying to accomplish and an example of a record where it is not behaving as intended. May 11, 2015 at 20:02
  • What is your desired behavior for the rule? Also, why are you mixing both types of operators? May 11, 2015 at 20:05
  • @ChrisDuncombe I updated the answer with more information. I thought the title was enough. When I find a record that meets the criteria of the rule, the rule does not fire. The rule should work like this: If Stage name is equal to Closed – Won or Closed-No Sale, the Opportunity_outcome field is not blank,the Primary_Reason_Won_or_Lost__c field is blank, and the user does not have the By Pass Opportunity Validation Rules permission then the rule fires. May 11, 2015 at 20:09
  • @Bri I didn't write this validation rule, so I'm not sure why the operators are mixed. I am just trying to get it to work as intended. It should work like this: If Stage name is equal to Closed – Won or Closed-No Sale, the Opportunity_outcome field is not blank,the Primary_Reason_Won_or_Lost__c field is blank, and the user does not have the By Pass Opportunity Validation Rules permission then the rule fires. May 11, 2015 at 20:11

1 Answer 1

1

If I'm understanding correctly, you want the formula to return true if ALL four of the following are true:

  • Stage name equals Closed – Won OR Closed-No Sale
  • Opportunity_Outcome__c is not blank
  • Primary_Reason_Won_or_Lost__c is blank
  • User does not have the By Pass Opportunity Validation Rules permission

Why do you have hyphens in the values for StageName? By default I believe they're just 'Closed Won' etc, unless your org changed them. Also, does 'By_Pass_Opportunity_Validation_Rules__c' appear in the available options when adding a merge field from global $User when viewing the rule? I'm unfamiliar with the syntax you provided for checking permission sets, but if you added it through the UI I'm sure it's valid.

Just concatenate the clauses, I broke them apart for readability.

AND (

OR(ISPICKVAL(StageName,'Closed - Won'),ISPICKVAL(StageName,'Closed - No Sale'),

NOT(ISBLANK(TEXT(Opportunity_Outcome__c))),

ISBLANK(TEXT(Primary_Reason_Won_or_Lost__c)),

NOT($User.By_Pass_Opportunity_Validation_Rules__c) 

)
2
  • in our org there are hyphens for all of the picklist values for Stagename. May 12, 2015 at 13:53
  • Alright, I edited them back. Just make sure they match the literals May 12, 2015 at 14:32

You must log in to answer this question.

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