 Hello friends, I am Sanjay Gupta. I welcome you on Sanjay Gupta Tech School. In this video, I'm going to demonstrate how you can lock opportunity when it is closed on or lost with the help of validation tool in Salesforce. Before starting, if you want to watch more Salesforce training videos, you can go to description of this video and you can find links of various playlist related to Salesforce videos. So now coming onto the topic, so let me first search opportunity object in the setup or in object manager. So I'm searching for the field that is stays. So we are going to use this stays pick list so that we can lock the record. And if it is in close one and close loss stays so you cannot add it the particular opportunity report. So that will be controlled through validation rule. So here you can see there is one stage as close one and one is as close lost and maybe any other value will be there that that is of tight close one or close loss. So no matters. Now, I'm going to create a new validation rule. So you can put rule name as per your requirements. So I'm putting lock opportunity record. So here you can write the description so lock opportunity record when it is closed on or lost. So this is the description. Now here we need to implement the validation condition formula. So there will be two scenarios. So I'm putting or outside and inside or there are two ends. So maybe this first and will be true or maybe second and will be true. So what will be the situation. So first situation will be like your stays is closed one or closed off and you are changing the state of the opportunity along with any other fields. So here I'm going to apply a function is changed. Name of the field is stays named. So this is the first condition of this and if stays is changed and prior value of is closed equals to true. So whenever you change the stays and it's prior value. Sorry prior value of is closest to it means the earliest case was close one or close loss and you are trying to change the stays to any other. So in that case, this validation will fire. Right. So this is the first scenario. Second scenario will be like you are not changing the stage and you are changing any other field on opportunity and your state your opportunity isn't close one or close lost space. So I'm putting not is changed stays name. Right. So you are not changing the states. And Is close equals to two. Right. So you are not changing the states and stays the list value is related to closed state. So in that case, you are trying to edit any other field. So in that case, also this validation rule will fire. So these are the conditions to which you can lock your opportunity to report. If you want to apply a profile chat report type chat that you can apply as well. So here error message, you cannot edit closed Opportunities and it will be displayed on top of the page. So I'm saving this. So this way I implemented the simple validation rule. Now I'm going to Change the stage of this opportunity. So right now it is prospecting. I am moving to close one and saving it right. So now I'm going to demonstrate both the scenarios that I implemented in the validation rule. So first time going to change the stays from closed Want to this proposal or price code. So in your projects or assignment they may be scenario like you will be asked to lock the Opportunity whenever it is closed one or closed so that any user cannot change the space once opportunities closed. So if I try to change the space so validation rule will fire and it will say you cannot edit closed opportunities. Right. And along with this if you try to change any other field then also the error will be seen right now second scenario is like your stages closed one and Then you want to change particular field. You are not changing the stage but you are changing the field value then also you don't want to allow this. So if you click on save so again you can say you can see you cannot edit closed opportunities. So in both the cases this validation is working properly. So it will pop Properly if your opportunities closed one or closed right because we implemented this is closed equals to true here. And if you want to apply a profile check if you want to apply report type check so that this validation will apply for a particular user or for particular report type and you can do that as well. So I hope you understood how we can lock opportunity when it is closed one or closed or lost with the help of validation rule so that no user can edit fields those are available in particular report. So if you want to watch more training video you can go to description of this video you will find links or various playlist related to Salesforce so you can watch them through. Thank you for watching this video.