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
CageMMACageMMA 

Validation rule help please

Hi all:

    I have the following scenario:

   If Applicable = true then

Period Months is required

and Either Amount or Percentage needs to be filled.

 

Here is my validation rule which is not working.

AND(
Is_There_a_Discount_Applicable__c = True 
&&
(ISPICKVAL(If_Yes_Period_months__c, "")),
AND(ISBLANK(If_Yes_Percentage__c) &&
 
ISBLANK(If_Yes_Amount__c)),

 $User.Alias <> "Merge")

 Now this works when I select Applicable = true and when the user clicks save it errors out. But then when you choose Period months and applicable = true then user hits save and it does not error out and saves the record, when it should error out and error out until percentage or amount is filled.

Thanks

Z

Best Answer chosen by Admin (Salesforce Developers) 
Rahul SharmaRahul Sharma

Hello CageMMA,

 

Have modified the rule for you, check:

(Is_There_a_Discount_Applicable__c && $User.Alias <> "Merge"
&&
ISBLANK(TEXT(If_Yes_Period_months__c)))
||
(ISNULL(If_Yes_Percentage__c) && ISNULL(If_Yes_Amount__c))

 Hope it helps.

All Answers

pankaj.raijadepankaj.raijade

test 'ISBLANK' for pick list as well instaind "ISPICKVAL"

 

you will have to convert pick list value to text and then ISBLANK.

 

Regards,

Pankaj Raijade,

Rahul SharmaRahul Sharma

Hello CageMMA,

 

Have modified the rule for you, check:

(Is_There_a_Discount_Applicable__c && $User.Alias <> "Merge"
&&
ISBLANK(TEXT(If_Yes_Period_months__c)))
||
(ISNULL(If_Yes_Percentage__c) && ISNULL(If_Yes_Amount__c))

 Hope it helps.

This was selected as the best answer
CageMMACageMMA

Thank you for the solution Rahul, it helped but Can you make it so that If both Percentage and Amount are filled in it errors out... It has to be either or?

Thanks

Z

Rahul SharmaRahul Sharma

Sorry i did not get it, can you explain in brief.

CageMMACageMMA

So if Percentage AND Amount are both filled in it needs to error out... Only one of them can be filled in. Thanks