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
Abhi MalikAbhi Malik 

Please Help For This validation

Duration and Enddate both are not null at same time , and if both are provied a value then the value of both is equal then only record will be saved. otherwise through an error.
the null part is done like this( ISBLANK( Duration__c )&& ISBLANK( End_Date__c ) ) but how to check the value of duration and enddate.
 
Best Answer chosen by Abhi Malik
Abhi MalikAbhi Malik
Yipee Done it 
OR(ISBLANK( Duration__c )&& ISBLANK( End_Date__c ), 
((Month(End_Date__c ) - Month(Start_Date__c )) <> Duration__c ))

All Answers

sailee handesailee hande
Hi Abhi,
 
Validation rule should be as :
OR(ISBLANK( Duration__c ) && ISBLANK( End_Date__c ), Duration__c != End_Date__c )

If this works for you then let me know.

Regards,
Sailee
Abhi MalikAbhi Malik
Thanks Sailee
but its not working throwing an  Error: Incorrect parameter type for operator '<>'. Expected Number, received Date, because duration is a number field and enddate is a date field , but if i want the duration then i need to subtract startdate from enddate.
Abhi MalikAbhi Malik
Yipee Done it 
OR(ISBLANK( Duration__c )&& ISBLANK( End_Date__c ), 
((Month(End_Date__c ) - Month(Start_Date__c )) <> Duration__c ))
This was selected as the best answer
Ankur Saini 9Ankur Saini 9
Hi Abhi,

Which type of duration field u have? If it is of number type try this:


OR(ISBLANK( Duration__c ) && ISBLANK( End_Date__c ), Duration__c != Month(End_Date__c) - Month(Start_Date__c) )


If it works, please let me know.

Thanks
Ankur Saini
http://mirketa.com