function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
PProkesPProkes 

Validation Rule formula has no errors, but doesn't work

The formula below has no errors, yet the only time a DFS Opportunity cannot currently be saved at "Submitted to Sales Support" is when the Soft Costs rule applies. Any advice on why the rule doesn't work for the Term and Pay Method component of the formula? When either of the 3 rules (i.e. 1 or 2 or 3) apply, then the opportunity shouldn't be able to be saved at "Submtted to Sales Support".

 

OR (
AND (
$RecordType.Name = "AUS : DFS : Opportunity Record Type" ,
Soft_Costs_percentage__c>0.2,
Soft_Costs_Approved__c =FALSE,
ISPICKVAL (StageName,"Submitted to Sales Support : DFS"
),
OR (
AND (
$RecordType.Name = "AUS : DFS : Opportunity Record Type", Term_Approved__c = FALSE,
IF (
Term_mos__c >
VALUE
(
Master_Lease_Agreement__r.Term_Exc_Interim_Not_To_Exceed_Mths__c
) , TRUE,
ISPICKVAL
(
StageName,"Submitted to Sales Support : DFS"
)
)
),
OR (
AND (
$RecordType.Name = "AUS : DFS : Opportunity Record Type" , Pay_Method_Approved__c = FALSE,
ISPICKVAL ( Account.Pay_Method_M__c ,"DDR"),
ISPICKVAL (Pay_Method__c ,"INV"),
ISPICKVAL (StageName,"Submitted to Sales Support : DFS"),
OR ($RecordType.Name = "AUS : DFS : Opportunity Record Type") ,
Pay_Method_Approved__c = FALSE,
ISPICKVAL ( Account.Pay_Method_M__c ,"INV"),
ISPICKVAL (Pay_Method__c ,"DDR"),
ISPICKVAL (StageName,"Submitted to Sales Support : DFS")
)
))))

*werewolf**werewolf*

As I mentioned in your other post, tabification is your friend.  If you use Notepad++ or Textpad to tab this formula out properly, it will help to highlight the mistakes.

qsdunnqsdunn

Werewolf gives good advice.

I tried tabifying your code and became obvious your parantheses are all wrong.

 

Your third rule is positioned [i]inside[/i] the OR function of the second rule, which in turn is positioned inside the AND function of the first rule, which is the [i]only[/i] parameter of the outermost OR function.

It's tricky to describe in words but when you indent the code properly, you can see how the three rules are not equal but are each get progressively deeper into the structure.