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
twrig15twrig15 

Validation Rule to Restrict Creation of a record

Hi Everyone,

I have 3 validation rules that looks a qty of a field and the available qty on the account record and it restricts creation if the login in qty is > than the available qty.

The issue is that I have 3 separate validation rules that looks at the same Login Qty field is the and when they are all activated that conflict with each other. Can you assist in creating a single formula that acts for the 3?

Formula 1: 
AND( Login_Qty__c > Account__r.Total_Of_User_Login_s_Available__c) 
&& 
NOT( No_Charge_Login__c = TRUE)

Formula 2:
AND(Login_Qty__c > Account__r.Total_Of_Systems_Login_s_Availab__c ) 
&& 
NOT( No_Charge_Login__c = TRUE)

Formula 3:
AND(Login_Qty__c > Account__r.Total_Of_Login_s_Available__c) 
&& 
NOT( No_Charge_Login__c = TRUE)

Thanks!
Best Answer chosen by twrig15
@Karanraj@Karanraj
Below are the two approaches you can use it
1. Below validation rule will fire if the Login_qty__c must be greater all the account 3 fields
AND( Login_Qty__c > Account__r.Total_Of_User_Login_s_Available__c,Login_Qty__c >Account__r.Total_Of_Systems_Login_s_Availab__c,Login_Qty__c >Account__r.Total_Of_Login_s_Available__c)
&&
NOT( No_Charge_Login__c = TRUE)
2. Below validation rule will fire if the Login_qty__c is greater than any one of the account field
view sourceprint?
OR( Login_Qty__c > Account__r.Total_Of_User_Login_s_Available__c,Login_Qty__c >Account__r.Total_Of_Systems_Login_s_Availab__c,Login_Qty__c >Account__r.Total_Of_Login_s_Available__c)
&&
NOT( No_Charge_Login__c = TRUE)

 

All Answers

@Karanraj@Karanraj
Below are the two approaches you can use it
1. Below validation rule will fire if the Login_qty__c must be greater all the account 3 fields
AND( Login_Qty__c > Account__r.Total_Of_User_Login_s_Available__c,Login_Qty__c >Account__r.Total_Of_Systems_Login_s_Availab__c,Login_Qty__c >Account__r.Total_Of_Login_s_Available__c)
&&
NOT( No_Charge_Login__c = TRUE)
2. Below validation rule will fire if the Login_qty__c is greater than any one of the account field
view sourceprint?
OR( Login_Qty__c > Account__r.Total_Of_User_Login_s_Available__c,Login_Qty__c >Account__r.Total_Of_Systems_Login_s_Availab__c,Login_Qty__c >Account__r.Total_Of_Login_s_Available__c)
&&
NOT( No_Charge_Login__c = TRUE)

 
This was selected as the best answer
Parker EdelmannParker Edelmann
@S.Karanraj, your code doesn't fully appear in the screen, but it is complete in the source code. Here it is:

AND( Login_Qty__c > Account__r.Total_Of_User_Login_s_Available__c,
         Login_Qty__c >Account__r.Total_Of_Systems_Login_s_Availab__c,
         Login_Qty__c >Account__r.Total_Of_Login_s_Available__c)
         && NOT( No_Charge_Login__c = TRUE)
The other code block just uses OR() instead of AND(). I would make a slight tweak though just for the appearance:

Login_Qty__c > Account__r.Total_Of_User_Login_s_Available__c &&
Login_Qty__c >Account__r.Total_Of_Systems_Login_s_Availab__c &&
Login_Qty__c >Account__r.Total_Of_Login_s_Available__c &&
!No_Charge_Login__c

@twig15, if you choose to go with this solution, please mark @S.Karanraj's answer as best, not mine.

Thanks,
Parker
twrig15twrig15
Thank you both! :)