In this post we will discuss an example of list validation in SharePoint 2013. Here I have an out of box Announcement list. In the announcement list there is a Title, Body and Expires column. The Expires column is a date and time column which indicates the expiry date of the annoucement. Here we will validate that the Expiry date should be greater than today. User should not add an annoucement which is already expired.
SharePoint 2016 provides out of box validation settings at the list level as well as in the column level. The difference between the two methods is that using the column properties does not provide ability to compare two columns in the same list, whereas the List Settings validation option allows us to validate using two columns. The column properties validation settings are useful when comparing a column value with a static value.
– SharePoint 2016 Fast Site Collection Creation using PowerShell
– SharePoint 2016 Create web application and Site collection using PowerShell
– SharePoint Server 2016 Installation Step by Step
You can create an Announcement App using Annoucement template. Then open the list and then from ribbon go to the LIST tab and click on List Settings button. This will open the list settings page.
In the List Settings Page, click on Validation settings which is presented under General Settings.
In the Validation Settings page, in the Formula it will display columns to insert into your formula. Write your formula like below:
User Message: Insert Future Announcements, this one already expired.
The formula looks like below:
Now try to add one annoucement and choose the expiry date as less than today. You can see a validation message like below and it will now allow you to add the announcement.
But if you will add an anoouncement whose expiry date is greater than today it will allow to add.
Hope this will be helpful