 Hello friends. I am Sanjay Gupta. I welcome you on Sanjay Gupta Tech School. In this video, I'm going to demonstrate how we can create validation rules in Salesforce. If you want to follow Salesforce training videos, you can search my name Sanjay Gupta on YouTube and you can follow my YouTube channel. So to create validation rules, first we need to identify on which object we want to create validation rule. So first let me open my university app. So in this app, we have one object tab that is book. And if I open any book record. So here we have various fields. So I'm going to apply validation rule on price first. So if I want to apply validation rule on book, so in Salesforce lightning, you need to search book object in object manager, open that. And if you scroll down, so at the bottom, you will see validation rules option. So click on this. So right now there is no validation rule on this object. So if you want to create new one, you need to click on new. So this window will be available. So here you can create a validation rule. So I'm going to create validation rule. Price should not be a negative rule. Right. And you can fill the description here. Price of book should not be negative. Right. Now, here you can implement a formula or condition. If this condition is true, then that validation rule error message will be displayed. Otherwise not. So you can read this. If this formula expression is true, display the text defined in the error message area. Right. So you can insert fields from here. You can insert operators from here. And if you want to use any pre implemented function, you can select it from here. Right. So I need to use. Price fields. So I'm selecting that. And I'm implementing this formula. Price underscore underscore less than zero. So if this condition is true, it means price field is containing values value that is less than zero, that is negative value. So this validation rule will fire and it will display an error message. Now I'm going to check syntax, whether I have implemented formula correctly or not. So no errors found. It means it is implemented correctly. Then the error message. So I'm writing price should not be negative. So this is my error message. Then where you want to display error message. So there are two other locations. First is top of page and second is feed. So if you are having only one feed in your formula, then. The best way is to choose specific field. So from here I can choose price. So this error message will be displayed just below the price field. Right. So you can also read this help text display your error message next to the field. The user should correct. If your validation rule checks several fields display the error message at the top of the page. Right. So if you have only one field, then choose this field and particular field. If you have multiple fields in your formula, then choose top of the page as a location. Now I'm clicking on save. So you can see a validation rule is available here and it is activated. So now we can test it. So first I'm going to edit this record. Then we will create new one. So if I'm editing this one and if I fill price as minus 500. So here you can see it is showing the error review the errors on the on this page and error message will be available just below the field. So this specific field is showing throwing an error. So error is price should be price should not be negative. So the error message and it is displayed just below the field. So this way validation rule works. So I'm canceling it. If I again edit and fill a positive value, then it will save properly. No error message is available here. Now if I create new record and I fill price as negative value. So again, you can see it is throwing an error message just below the particular field. So I hope you understood how we can apply validation rule. Now I'm going to create one more validation rule that will involve more than one fields. So again, I'm clicking on validation rule. So now you can see one rule is already available. Now we are going to create one more. So rule name is author. So we are going to check two things this time, author name and about author. So author name or about author blank. So right. So now, if anyone of this is blank, then this validation rule will fire. So we need to check multiple fields. Right. So we have to check blank here. So I'm going to use a function that is blank. So select is blank from here and click on insert selected function. So it is available here. Now I have to put a particular field. So about author and author name. So first time selecting author name. So if it is blank, then this rule will fire, but I have to check one more field. So again, I'm selecting is blank. And second field is about author. So I have to check both. So I am putting them inside or so all means any of these field is blank and this rule will be true and error message will be displayed. Right. And together if you want both at same time, then you can choose and also. So if you apply and then in that case, if at same time, both are blank, then only this rule will fire. But we want any one of this is blank. Then we want to fire this validation tool. So please fill author details. So this generic message and this should be displayed on top of the case because we are involving more than one piece for this validation rule. Now I'm clicking on save. So you can see this is active and error formula is or is blank author name comma is blank about. So now doing a refresh. So I'm clicking on edit. So here you can see author name and about author both are blank and I'm clicking on save. So you can see the error message is available here. Please fill author details. So now I'm going to fill only one. So I'm filling my name as Sanjay author name but about author is blank. Then also it will throw the error message because we are using or so any of this these fields are blank and this will throw an error message. This is test message. And now I'm leaving author name as blank. So again, this will throw an error. But if we fill both at same time, then this record will be updated successfully. So now you can see author name and about author both are available. Now similarly, if you create new record and without filling author name and about author, you click on save. So again, it will show an error message. So first you need to fill the book name. Then you need to fill author name and about author then only this record will be created. So this is how validation rule works for a particular object. So I hope you understood how we can create validation rule for a particular object. And I hope you understood how we can create validation rules. So if you want to watch more Salesforce training videos, you can search my name Sanjay Gupta on YouTube and you can follow my YouTube channel. Thank you for watching this video.