 Hello friends. I am Sanjay Gupta. I welcome you on Sanjay Gupta Tech School. In this video, I am going to demonstrate you how you can create duplicate rules and matching 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. Now coming on to the topic. So to create duplicate rule in setup, we need to search duplicate rules. So you need to click on duplicate rules. So on right hand side, duplicate rules page will be available. So if any existing rule is available there, so it will show. So here you can see three duplicate rules are already available. So now I'm going to create new rule. So if these existing rules are created on account lead in a contact objects, right? So if you want to create new rule, so you need to select a particular object. So let's say I am selecting student. So rule name student duplicate rule. If you want to specify any description so you can write it here and object is student that we selected then record level security. So it is saying if you want to enforce sharing rules, you need to click on first option. If you want to bypass sharing rule, then you can choose second option. So we want to apply sharing rules. So I am selecting first option. You can also read this help text so that you can read description properly related to record level security. So it says specify how your organization sharing rule determine which records the matching rule compares. So if you select enforce sharing rule, then it says the matching rule compares only records that the user has access to and the resulting list of possible duplicate includes only records the user has access to. Right. So if you select enforce sharing rule, then this will happen. If you select bypass sharing rule. So it says the matching rule compares all records regardless of user access, but the resulting list of possible duplicate includes only records the user has access to. Right. So I am selecting first one we want to use sharing rules as it is then under actions section it says specify what happens when a user tries to save a duplicate record. So on create and edit what you want to do. So you want to allow or you want to block right on edit you want to allow or block. So if you want to show an alert and report, then you can choose these checkboxes. Right. So you can choose these options accordingly. So if you choose allow then alert will be shown and duplicate rule duplicate record will be created if you want if you don't want to create then you can select block. So first time selecting allow then here we need to select a matching rule. So define how duplicate recalls records are identified. So we need to select a matching rule on the basis of that matching rule. This duplicate rule will work. So it is saying the label as compare students with so we can compare student record with other records as well. So you need to select a particular object. So I am selecting student here. So matching rule. So right now we don't have any matching rule. So I am selecting create new matching rule. So before that it is asking for save this duplicate rules. I'm clicking on save. So now it is opening matching rule. So for duplicate rule this matching rule will be created. So here you need to specify matching criteria. So tell the rule which feels to compare and how. So we need to select a particular field. So let's say I'm selecting email. Right. Then matching method. So exact. So if two emails on two different records matches exactly then this matching rule will be true and that duplicate rule will fire. Right. You can select more than one feels also and then you can apply this filter logic. So you can use and or condition if you have multiple people selected here. Then this checkbox is match blank fees. So you can read this help text to understand what it does. So it says if you select this option for any field then that field is blank in both of the records being compared. The fields are considered matches. Right. So if you click on this checkbox and email field on two records are blank then that should be considered as duplicate. Right. So right now I'm leaving it as unchecked. So clicking on save. So matching rule is created. So here you can see matching criteria is for student and email exact match blank is false status is inactive. So if you click on active so it will be activated. So it is activated. Right. Now we need to go to duplicate rule again. So here it is student duplicate rule. And here you can see it is by default available here because we created matching rule through duplicate right now again I'm clicking on edit. So here your matching rule is available. So if you have created matching rule already. So you can directly select that matching rule from this drop down. Right. Then if you want to specify any condition. So though though it is optional. So optionally specify the conditional record must meet for the rule to run. So if you want to specify an optional condition. And if this optional condition is matching then only your duplicate rule will run so you can specify that here. So right now we are not specifying it we want to We want this duplicate rule to run for all the records. We don't want to specify any entry condition for the duplicate rule. So now I'm clicking on save. So here you can see duplicate rule is created. It is having matching rule but right now it is not activated. So I'm clicking on activate. So now it is activated. It will work on create show and alert and report and it will not work on edit because yeah it will work on edit but it will not show any alert or report right. So now I'm opening my university app where that student tab is available. So here we have student then let me open this one. Yeah. So here email is not available. So right now I'm filling. So I filled this email address. So it is saved opening another one. It is also not having. So now I'm going to type same email address. And clicking on save. So on editing it is saved. Now I'm clicking on new and I'm going to create one student record. So name is test duplicate rule and here and this email address is already available for existing records. So here it is showing an alert message. The record you are about to create looks like a duplicate open an existing recording sheet. So if you click here. So it will show you all the duplicate records. So all these three records are having that email ID right but it will allow you to create this record because if you notice that on both create on on sorry on both create an edit we selected allow. So duplicate to record will be created on edit. It was not showing any alert report on create it was showing alert report but on both the scenarios. It is allowing us to create new record. That is duplicate also. So now I am blocking this and clicking on save. So this time it will not allow to create duplicate record or if we added existing one which the email ID that is already available with a particular record then it will show an error message. So now if I try to create new record and click on save. So here you can see this record looks like a duplicate view duplicate. So four records are already having that email ID. So now if I click on save so it is not allowing me to save this record. So this is because we clicked on the selected block as the biggest value. So I hope you understood how we can create duplicate rules and matching rules so that we can respect creating duplicate records for a particular object. So you can you can select two options like allow or block. So if you select allow then alert will be thrown and duplicate to record will be created but if you select block then alert will be thrown and duplicate record will not be created. So I hope you understood a duplicate rule and matching rule that I demonstrated in this video. If you want to watch more Salesforce training videos you can search my name Sanjay Gupta on YouTube and follow my YouTube channel. Thank you for watching this video.