1
IF( ISBLANK( Close_By__c ), TODAY() - Open_Date__c , Close_By__c - Open_Date__c )

When i am using this formula for close date validate. An error is occurring like:

Error: Formula result is data type (Number), incompatible with expected data type (true or false).

Can any one please help me out, where is the mistake?

1
  • Welcome to salesforce.stackexchange Monika. Please try to find related tags to a question, this will help attract people with the right knowledge to your question. Based on the content of your question i've attempted to do this for you, feel free to edit if I've done so incorrectly. – Samuel De Rycke Oct 22 '14 at 13:54
1

Validation formulas should result in either True or False, this result expresses whether what you're testing is valid or not. Actually, you want to test for invalidity:

This message will appear when Error Condition formula is true

For instance: if you want your validation to fire when there is no close date, this should be sufficient:

ISBLANK( Close_By__c )
4
  • Thank you for helping me out. But my question is i have a 2 fields with data type Date:Open_Date__c and Close_Date__c ,Now i want to validate the open_date automatically if Close_date is blank it should be today or i want number of days (Open_Date-Close_Date).How to use the formula in right way. – Monika Oct 22 '14 at 14:05
  • 1
    @Monika please update your question with the additional information in your comment; this will ensure that someone trying to answer you sees all relevant information. Also, it's still not clear what you are asking; a validation rule only tests if a value is invalid (so that the system can flag it as invalid). How does number of days affect validity? Are you trying to ensure a minimum number of days between? what is that minimum? – Jason Clark Oct 22 '14 at 14:49
  • Thank you @ Jason .Now i understood i should not use validation over here i need to use a formula field Then it works.Thank you all for helping me. I am new to salesforce plz excuse me if my questions are silly or not proper. – Monika Oct 22 '14 at 16:36
  • It's ok to be new. Remember to try to give answers which are detailed enough to answer, yet skip unnecesairy information. And for salesforce, validation is to block data entry when it's not correct, if you want to automatically do things you need workflow/formula fields or apex (code) triggers if complex. – Samuel De Rycke Oct 22 '14 at 16:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.