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
Rachel LinderRachel Linder 

Help with Writing a Validation Rule for Our Credit Check Process on Opportunites

We are trying to write a validation rule when moving an opportunity from the stage "Commit" to either the stage of "Closed Won" or "Closed & Booked". The scenarios are:

User-added image

Currently I have written the followng which I believe covers the first line and the last line when moving to "Closed Won". I will need to add an OR for the StageName to include "Closed & Booked":
AND((ISPICKVAL(StageName, "Closed Won")),

AND(
NOT(ISBLANK(Account.GP_Customer_Id__c )),
Amount > 100000,
NOT(ISPICKVAL( Credit_Status__c , "Approved")),
NOT(Credit_Approved_Amount__c >= Amount ),
NOT(Credit_Expiration_Date__c >= TODAY())))

I have tried building on this with the formuale below but I am getting an error stating something along the lines of "Expected 3, Received 1". I am not sure if I am even on the right path with the informaton below (again right now this is for the stage "Closed Won":
 
AND((ISPICKVAL(StageName, "Closed Won")),
 
IF(
AND(
(ISBLANK(Account.GP_Customer_Id__c )),
NOT(ISPICKVAL( Credit_Status__c , "Approved")),
NOT(Credit_Approved_Amount__c  >=  Amount ),
NOT(Credit_Expiration_Date__c  >= TODAY()))),TRUE,
 
IF(
AND(
NOT(ISBLANK(Account.GP_Customer_Id__c )),
Amount > 100000,
NOT(ISPICKVAL( Credit_Status__c , "Approved")),
NOT(Credit_Approved_Amount__c  >=  Amount ),
NOT(Credit_Expiration_Date__c  >= TODAY()))),TRUE,
 
IF(
AND(
NOT(ISBLANK(Account.GP_Customer_Id__c )),
Amount < 100000),TRUE,FALSE
)
)
AND((ISPICKVAL(StageName, "Closed Won")),
 
IF(
AND(
(ISBLANK(Account.GP_Customer_Id__c )),
NOT(ISPICKVAL( Credit_Status__c , "Approved")),
NOT(Credit_Approved_Amount__c  >=  Amount ),
NOT(Credit_Expiration_Date__c  >= TODAY()))),TRUE,
 
IF(
AND(
NOT(ISBLANK(Account.GP_Customer_Id__c )),
Amount > 100000,
NOT(ISPICKVAL( Credit_Status__c , "Approved")),
NOT(Credit_Approved_Amount__c  >=  Amount ),
NOT(Credit_Expiration_Date__c  >= TODAY()))),TRUE,
 
IF(
AND(
NOT(ISBLANK(Account.GP_Customer_Id__c )),
Amount < 100000),TRUE,FALSE
)
)

Any feedback on if I am going in the right direction? If I am 100% in the wrong or going down the wrong path what do we need to write for the rule? We have been working on this now for 2 days with no such luck.
Thanks in advance.
Jason Curtis NBSFDGJason Curtis NBSFDG
Rachel, have you tried breaking these out to separate validation rules to reduce complexity--it looks likes the three of then are mutually exclusive. As for the "Closed Won" or "Closed Booked", do you want to capture errors any time a record goes to this stage or only if moving from "Commit"? If so you need to use the PRIORVALUE function.
Rachel LinderRachel Linder
Jason, we want to capture this anytime it gets moved to "Closed Won" or "Closed Booked". So, if we were to do three rules how would we capture the OR on the stages of "Closed Won" or "Closed Booked".
Jason Curtis NBSFDGJason Curtis NBSFDG
I was looking at the first column as your initial validation rule section, if GP ID is Blank, and Amount is > 100K, then a sub rule about if Stage = OR(Closed Won, Closed Book) and then the following validation rules. Might help to separte out some of the complexity. Also, can the opp be moved to Closed Won or Closed Booked for a different state than Commit without triggering any validation?