 Hello friends, I'm Sanjay Gupta. I welcome you on Sanjay Gupta Tech School. In this video, I'm going to demonstrate certain cases while creating validation rule. So first is when record is created and edited. So validation will work in both the scenarios. Second, when record is created only so we want our validation rule to run when record is created only if it is edited that validation rule should not work. And third is it's vice versa. So if record is edited, then validation rule should fire. If record is created, then it should not fire. Right. So before starting, 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 I created a validation rule on opportunity. So this validation rule is if an amount is not blank and description is blank, then this validation rule will fire and it will throw an error message that is please fill description. Right. So right now it will work in both the scenarios while creating opportunity record or dating record. So let me create new opportunity. So its name is test. Close date stays so I filled all these details. Now I'm filling the amount. So if amount is not blank and description is blank and I tried to save it. Sorry, this is not active right now. So that's why it won't work. So I'm activating this. Again, I'm creating new opportunity record amount, but description is blank. Now if I try to save it so you can see review the errors on this page. So it is showing please fill description like if you fill the description then only this record will be saved. Now I'm removing this amount and I'm saving this. So it is created because amount was blank. Now if I try to edit this record by filling amount and I try to save it. So again, this will throw an error message. So it is for description because amount is filled and description is blank. So this way it is working on both creation and updation. Now our second scenario is when record is created only so it should work while we are creating new record. So we need to update this validation rule. And I'm going to add a simple condition here that is is new. So this is added. So if record is new amount is not blank and description is blank then only it will fire right. So I'm saving this record. Sorry, I'm saving this validation rule. Now I'm refreshing it. So you will see on updation it will not fire amount will be filled and description will be blank still be will be able to edit and save the record filling the amount only description is blank. So you can see this record is saved and you can see description is blank. So on updation validation rule is not working. Now if I try to create new opportunity record and if I fill amount and leave description as blank. So you will see this is throwing an error message please fill description right. So this is covering the second scenario that is firing on creation only now we need to revert it for editing only. So I'm editing this validation rule. I'm just putting not with his new. So if record is not new, then this validation will fire so on updation it will fire on record creation it will not fire. So here, if I open this record. So here it is. So let's try to create new record. So I'm filling me close date and stays only. I'm populating amount as well description is blank still it will create this record right. So if I edit this record amount is filled but description is blank. And if I try to save this so it will throw an error right so this way you can use is new method. Whenever you want your validation rule to work for the record creation or record modification accordingly you can modify your validation rule. If you want your validation rule to work for both the cases then you can remove this is new method. So this way we can implement all these scenarios while implementing validation rule. I hope you understood whatever I demonstrated in this video. If you want to watch more salesforce training videos you can search my name Sanjay Kutna on YouTube and you can follow my YouTube channel. Thank you for watching this.