Wednesday, May 28, 2014

SharePoint 2010 list Column/Field Validation


My customer wanted to be able to make a Column/Field Validation for a SharePoint 2010 List column. Date column(Date1) needs to be validated so that it is greater than 3 days from today but this column is not a required column so it makes little tricky.

 Initially I was using the below simple formula for my column validation,
 =[Date1]>NOW()+3

It works great if there is a value in the Date1 column/field but I ran into an issue when there is no value in this column/field because the validation is triggering. The formula must evaluate to TRUE for validation to pass.

 So I came up with the below formula which uses IF condition,
=IF(Date1]<>"",IF([Date1]>NOW()+3,TRUE,FALSE),TRUE)

If Date1 is not Empty  then I want to make sure that Date1 has a value which is greater than 3 days from today so I go into the second IF statement which will return a TRUE if Date1 is greater than 3 days from today or FALSE if it doesn't match.   If Date1 is empty  or has no value then I don’t care so I will always return TRUE.


If we need to validate 2 fields then we should be using List Validation feature

 

No comments:

Post a Comment