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
khushbu dubeykhushbu dubey 

i have written validation rule for basic pay with allowance..is it correct?

IF( VALUE(text( Basic_Pay__c))*0.20 ,  TEXT( Allowances__c )='HRA'   ,VALUE(text( Basic_Pay__c))*0.3O ,  TEXT( Allowances__c )='TA' ,VALUE(text( Basic_Pay__c))*0.40 ,  TEXT( Allowances__c )='CA',VALUE(text( Basic_Pay__c))*0.35 ,  TEXT( Allowances__c )='DA'   ))

 
Deepak GulianDeepak Gulian
IF(expression, value1, value2) 
If expression is true then value = value1 else value = value2
this is how IF condition works, so it not seems correct formula to me, so can you explain your condition for validation rule
Parker EdelmannParker Edelmann
Is this what you're looking for?
​VALUE(text( Basic_Pay__c))* CASE(TEXT( Allowances__c ),
                                       'HRA', 0.20,
                                       'TA', 0.3O ,
                                       'CA', 0.40 ,
                                       'DA', 0.35 ,
                                        ___ /*your if-all-else-fails value */)
However it is nowhere close to a validation rule, as it returns a number, not a true or false value. Like Deepak Gulian mentioned, the IF function returns value 1 if the expression is true, and value 2 if it is false. The CASE function takes a value, in this instance TEXT(Allowances__c), and checks it against a series of values. If the expression matches one of those values, it returns the corresponding value, if not, it returns the "else" result.
khushbu dubeykhushbu dubey
sorry,but it is not  working
Parker EdelmannParker Edelmann
Can you give a little more information on what you're trying to accomplish? I can't tell you how to fix something that I don't know what its purpose is.
khushbu dubeykhushbu dubey
Actually..i want to get the output like that if only( basic pay)  then allowance will be 'hra' ,if (basic pay *0.30) then allowance will be 'da', if (basic pay *0.40) then allowance will be 'ta', if (basic pay *0.50 )then allowance will be 'ca'.here both allowance and basic pay are picklist.
Deepak GulianDeepak Gulian
Like you said both fields are picklist , then best solution for this situation is use Field Dependencies.
Basic Pay ---> Controlling Field
Allowance ----> Dependent Field