Learn SharePoint In Series - Part Eight - Validation Settings In List Settings

Introduction

This article is part 8 of the SharePoint series. You can find previous articles of the series here.

  1. Learn SharePoint In Series - Part One - Introduction
  2. Learn SharePoint In Series - Part Two - Web Application
  3. Learn SharePoint Series - Part Three - Site Collections
  4. Learn SharePoint Series - Part Four - Subsites
  5. Learn SharePoint Series – Part Five – SharePoint Lists
  6. Learn SharePoint In Series - Part Six - Power Of Versioning
  7. Learn SharePoint In Series - Part Seven - Lists Advanced Settings

In the previous article, I have explained about various list level settings available in SharePoint.  Now in this article, I am going to cover the validation settings available in SharePoint list.

In this article, I am going to cover the following topics,

  • Introduction to List Validation Settings.
  • How we can use these validation settings
  • Benefits of configuring the list level validation settings.
  • Available functions and statements in Validation Formula
  • Summary.

Introduction to List Validation Settings

If we talk about validations in SharePoint, then SharePoint provides mainly 2 levels of validation settings.  In this article, we will be discussing validation settings applied at the list level. We will explore the field level validation later on in this series.

Consider a real-world scenario where you have a list new item form with multiple fields. And now you have a requirement that the Obtain Marks should be less than the Total Marks. If the condition doesn’t satisfy then the item should not be added. We can apply this validation using list level validation as well as column level validation. But here we will be exploring the article via list level validation.

How we can use these validation settings

In order to go to this setting page, please follow the below steps.

Step 1

Open the list in which you want to apply validation settings and click on List Settings.

SharePoint
Step 2

Click on Validation Settings

 

Step 3

Add your formulas to the Formula section.

SharePoint

 

Here, what we want is that the item should not get saved if the Obtained Marks is greater than Total Marks. Then the formula will be like.

  1. =[Obtained Marks]<[Total Marks]  

Enter the text message that should be displayed if the validation fires and click on Save. Now open the list new item form. Try to enter value 25 into Obtained Marks and 50 into Total Marks and submit the form.

SharePoint

 It will save the record into the list as validation checks if the data are correct. Now, again, try with entering 50 into Obtained Marks and 25 into Total Marks and then try to submit the form. You will get the error message that you have specified in the Validation Settings.

SharePoint

 

So validation settings work in the explained manner.

Benefits of configuring the list level validation settings

As I said, the validation can be specified in list level and field level. Every approach has its own benefits and limitations. If you want to display the field wise validation message then you can write the field level validation code. But if you want to generalize the validation message and you want to manage every validation in one place then, in that case, you can use List Level Validation Settings.

Major benefits of configuring validations at list level are, we have to write every formula in the one box and one general validation message is enough. This validation check is executed when we submit the form.

Available functions and statements in Validation Formula

We already know some of the programming statements such as IF, Else and functions like Date Functions etc. Validation Formula also has its own set of Statements and Functions. The complete list of formulas and functions are available here Examples of common formulas in SharePoint Lists

Also, there is a well written and great post on the same topic already available in CSharpCorner here Validation Settings In SharePoint 2013

We have the following types of formulas available.

Conditional Formulas

In conditional formulas we can make use if IF, AND, OR, NOT, ISERROR, ISBLANK formulas available. For example, let’s demonstrate the use of IF statement in SharePoint List Validation and in traditional c#.

IF works the same as If statement in C#, the only difference is with syntax. In C#, we write IF as,

  1. if (Condition) {  
  2.     // Condition is true  
  3.     Execute Success part  
  4. }  
  5. Else {  
  6.     // Condition is false  
  7.     Execute Failure part  
  8. }  

While if we write the above same situation in List Validations settings, it would be written as,

  1. =IF(Condition,”Success Part”,”Failure Part”)  
Summary

So in this article, we have seen how list validation settings work, although it's the basic information about how we can configure the list validations with a straightforward example. Utilizing list validation settings we can also configure business level validations using some complex level of formulas.

In the next article, I will be talking about audience targeting settings available in List. If you have any suggestions or questions please feel free to post a comment.