Salesforce Certified Advanced Administrator – Data Management Part 2
May 16, 2023

3. Conditional Validation Rules by User Profile

All right, so in this lesson we’ll look at conditional validation rules by user and we’re going to do a validation rule that checks against the user’s profile. So we’ll show an error if it’s a certain profile and not if it’s a different profile. But before I dive into that I wanted to show you this knowledge article 213868 common Regex validation. I felt like I needed to give you some further resources that will help you with understanding some of example regex formulas so you can make sure that things are in the proper format.

Some good examples here would be Social Security numbers and American zip codes, five or nine digit and then just straight out just gives you the regex code that you can pop into a formula for validation rule. And there’s a lot more in here such as Brazilian and Japanese zip codes, et cetera. And then as well other additional resources have to do with formula operators and functions, link for regex and Java regex documentation as well.

And so you can feel free to check that out to your heart’s content. But let’s dive into other validation rules. Let’s change this one that we previously created so that it only will show an error if it’s a user that has a certain profile. So we have our beginning and here and then we have our different logicals. The first logical was this or and then the second logical was this not. And so what we want to do is add another logical inside of this and remember the ands include logical separated by commas inside of the parentheticals we have the logical one, we’ve got the logical two. And so now let’s add a third logical. I’m going to add a comma just before the closing parenthetical which belongs to this first opening parenthetical.

So we know that we’ve got our first two logicals here. So we’re going to add the comma. And so now next I want to check against a profile for the user that’s entering or editing an account record. So I’m going to click Insert Field, and then instead of an account field, I want to select User. Or better yet, even rather than pulling up User, I could go a couple of different ways on this, actually. I could go User, and then I could select Profile ID, and then I would have to go in and hard code in the ID that I’m checking against. Or what I could do is I could select Insert field and select Profile and select the name and insert that and let’s say equals System administrator.

So this is our third logical. Let’s check syntax. So if this works and we have no errors, which I’m anticipating, I’m going to have an error. It’s kind of normal to get things wrong and have to wash, rinse, repeat and try a few times before you get your formula. All right, and working that’s okay, let’s check syntax and when you know it no errors. Woohoo. So now not only is it checking to see if any one of these three billing countries for Can, CA or Canada is filled in and then it’s also checking the format for the Canadian postal code but it also is now going to check if the user’s profile is equal to system administrator. So if all these three logicals are true then it will throw the error.

So now I’m going to click save and what we’ll do is we’ll test this out and so let me edit this and put this in the wrong format and I’m in the system administrator profile so this should show an error for me. Let me click save and so now it is showing the error. Now I want to show you the inverse of that. Rather than logging in as a different user, I’m going to change my actual validation rule and say that that third logical is not equal to system administrator. That’s the quickest way to test that out. Now one thing to note is that the operators here actually I don’t think the bang equal, this is more Apex code or Sachal query code would have not equal. Let me check the syntax to see if that will recognize that operator. It’s saying no errors found. So we’ll see if this works.

But the actual not equal recommended operator is the less than and greater than combined together to be not equal. But let’s just try it this way. It said, no errors found. So we’ll click save. And so now let me go back to this tab. Let me cancel out of this. Let me refresh so that we hit the server again, which pulls in any potential validation rules on the object behind the scenes. And let’s go to details on the account. Let’s go to the billing address and let’s change the billing postal code again. Now remember, we’ve changed this to be the inverse so that if the profile is not system administrator, that’s the third logical and validation rule, it will evaluate the true and show the error. But since we have system administrator, my theory is that it shouldn’t show an error and it should let me do this. So we’ve in essence created a validation rule that allows system administrators to have extended privileges and to be able to purposefully enter bad data, for example.

And there’s times that you’ll need to do that as an advanced administrator. A good example of this is even in my own real life project that I’m working currently, there were some situations where I was not able to enter bad data and I needed to in order to run some tests and to see and troubleshoot because of bad data in the past that has been cleaned up through validation rules.

And so the way that you can extend certain rights to admins but not other users is to do a validation rule where you’re adding another conditional where you’re making sure that the profile is not equal to system administrator like we’ve done here. So be sure and check out the ways that you can pull in other field values not only on the object that you’re on but also there’s a lot of other options as far as object types and organization type information. You can get down to latitude and longitude for example and as well profiles such as we’ve seen there system user and user role which has to do with the role hierarchy as well. So you can get very granular and specific in validation rules are very powerful tool to help you to ensure data quality in your salesforce organization. And now another helpful tool with data management and the quality of data would be duplicate management and we will dive into that starting in the next lesson.

4. Duplicate Management

Good management. Now, there’s primary tools available that Salesforce provides to avoid or try to prevent duplicate records from being entered and those would be duplicate rules. And then inside of those duplicate rules are matching rules. There’s a lot of limits on duplicate rules and you don’t necessarily need to know all the ins and outs of the limits on duplicate rules for the advanced admin exam, just as an example, you can have up to five active duplicate rules per object is one of those limits. Now, if you notice there’s a standard duplicate rule on account contact and lead objects and you see that these are active, these came out of the box with the free Salesforce account and they’re associated with these different objects. Now you also notice that the duplicate rule has a corresponding matching rule or matching rules. The account duplicate rule has one standard account matching rule. The contact duplicate rule has two matching rules in it, and the lead duplicate rule has two lead matching rules inside of it as well. Speaking of matching rules, you can have up to three matching rules in each duplicate rule. So five duplicate rules per object, three matching rules per duplicate rule. Now, the matching rules need to be active and the duplicate rule needs to be active as well.

So if we look at the standard account duplicate rule, let’s click on that, that gives us the detail for the standard account duplicate rule. There’s a lot that goes into this and I’ve learned more than I ever cared to about duplicate rules in my day job. But I want to pass along what I’ve recently learned about duplicate rules so that you can benefit from my experience. And we will cover duplicate management over the next several lessons because there’s a lot to cover here. So the duplicate rules will have a name and a description and the object that it’s associated with, and then the record level security. You can set this to either enforce sharing rules, meaning that whoever the user is that’s trying to enter or edit a record in this example would be an account. This duplicate rule will either only look at potential duplicates for those records that the user has access to, or you could change the record level security to bypass the sharing rules.

Now, bypassing the sharing rules will then give them orgwide access, at least not to be able to see those records. But the duplicate rule will be able to check for potential duplicates outside of records that the user would normally be able to see based on where they are in their role hierarchy. And so here’s a good explanation of this as far as bypassing sharing rules. The matching rule compares all records regardless of user access, but the resulting list of possible duplicates includes only records the user has access to. So I will say that there’s potential duplicates, but if they don’t have access to the record, they won’t be able to see that record. I’m going to go ahead and change that back to the default though of enforcing the sharing rules. Now there’s different actions you can set.

So we got the rule details here at the top and we’re in a duplicate rule. Remember. Now we’ll get to matching rules here momentarily. So beyond the rule name, the description, the object and the record level security, in the action section, you can do different actions based on the create and edit of a record. So when you first have someone creating a record, you can either allow them to create the duplicate or block them from creating the record if there’s a match. So if you allow you can either alert the user and say, hey, this is a potential duplicate and or you can report. That means that this will create a duplicate record set and that’s something that is reportable and is a separate object. So as we go deeper down this rabbit hole, let me show you in the app launcher, if you go down to all items, there’s this object here called duplicate record sets. I’m going to right click and open this link in a new tab so I can show you what that looks like momentarily. Now this is a record of any potential duplicates and it’s defaulted to recently viewed. We’ve not looked at any duplicate record sets yet, but let’s see if we have any in our from just our own traversing our free salesforce account.

And there are some standard duplicate rules out there. So we may have some duplicate record sets which these are recorded whenever there’s a potential duplicate and it’s reported inside of your salesforce instance. So I’m going to just call this all duplicate record sets and let’s just go ahead and say all users can see this list view and click save. And so then filters filter by owner. So we don’t have any duplicate record sets. So as we start doing duplicate management and putting this to use, we will start to populate some duplicate record sets. But I wanted to make you aware of how this alerting and reporting will bring in duplicate record sets. If we report on those potential duplicates. Now we are allowing on create and on edit, but you could block users from creating duplicates and that’s up to your organization or to yourself as to what you want to allow or not allow. And then as well the alert text, if you’re alerting someone, if you check here to alert, then here’s what the text will appear as to let them know, hey, this is a potential duplicate. Now for the matching rules, you can compare accounts with other accounts or these other objects here.

So you can actually search for duplicates across other objects such as contacts. A common example is comparing leads versus contact records, but you can do other objects as well. But I’m just going to compare with accounts and use the matching rule, the standard account matching rule. Now remember, you can have one or multiple matching rules inside of a duplicate rule. So let me go ahead and save this and let’s look at the matching rule. So the standard matching rule on accounts, let me deactivate this. I need to deactivate it to see how it’s set up. But let me go in instead to the duplicate rule that’s housing this. And let me deactivate the standard account duplicate rule momentarily. So click deactivate. And so now if we go into the matching rule, we can deactivate it and then once it is deactivated, let me refresh, the edit button will appear so we can’t actually edit the standard matching rule.

I was thinking about a custom matching rule because I’ve had to create a lot of those recently and able to edit. But for the standard account matching rule, if you want more details on how that works, there’s all this information around match keys and some examples. This gives you an idea of what is considered a potential duplicate. There’s also threshold scores. This has to do with match confidence. And if you’re getting into Apex development, there’s an Apex method called Get match confidence that I’ve had to deal with recently. And so you can set or return that match confidence to see and get scores around how strong or loose a match may be.

And you can set thresholds on that to appear as well. Now, we’re just dealing with standard rules here, so probably what we should to do, let me go ahead and activate this, click OK and go back to the duplicate rule and activate it as well. And let’s go ahead and create an additional duplicate rule because I want to talk about some of these other things such as reordering these duplicate rules. And so let’s in the next lesson create a new account duplicate rule.

Leave a Reply

How It Works

img
Step 1. Choose Exam
on ExamLabs
Download IT Exams Questions & Answers
img
Step 2. Open Exam with
Avanset Exam Simulator
Press here to download VCE Exam Simulator that simulates real exam environment
img
Step 3. Study
& Pass
IT Exams Anywhere, Anytime!