Salesforce Certified Platform App Builder – 3 – Data Modeling and Management Part 4
- Creating an Encrypted Field
So let’s now create an encrypted field. And so I’m on the Contacts tab and the All Contacts list view. And so we’ve been dealing with some contacts previously and if we look at for instance, this contact name Arthur Song, who’s with United Oil and Gas Corp. For instance. And so this is just a typical contact record. And we’ve got our Related list here with our Related have with the News feature and then as well as some of the related lists for opportunities, cases, et cetera. Then on the Details tab we have the various fields for the contact record such as email address and phone numbers and mailing address. So when you think about an encrypted field, a good use case for this would be to encrypt like a Social Security number for instance, that contains sensitive information that you want to protect further. So in our scenario, let’s have an example of where we want to also have contact records for our own employees and have an integration with an HR system, human resources system, and where we keep track of our own employees information.
And one sensitive piece of data that would need to be encrypted would be the Social Security numbers. And so I’m going to go to the Object Manager by clicking Set Up Home and then explore objects to go to the Object Manager. And then on the Contact record we want to add this encrypted field. And so I’m going to click on Contact from the list of objects and then Fields and Relationships and then the new button. And so now I want to select for my data type of the new field. I want to select down here towards the bottom text and then Encrypted appears in parentheses and this allows users to enter any combinations of letters and numbers and store them in encrypted form. And then you can also look for further information by hovering over this icon here. It says Text entered into this field. It’s encrypted using classic encryption. If you click on that you can get further details around what Classic Encryption is and how it works and all the ins and outs of the encryption and what you can and can’t do. If you want to explore further, I encourage you to explore that link that’s available that I just clicked on. This tells you the difference between Classic Encryption and Shield Platform Encryption, which has to do with the Salesforce Shield, which is a newer release and gives you higher level of encryption.
If you notice, the encryption algorithm through Classic Encryption is 128 bit, whereas Salesforce Shield provides 256 bit. And there’s other higher levels of encryption through the Salesforce Shield solution which the extra fees apply for that. So if your requirements are like in healthcare industry or financial services, a lot of times you’ll need a lot of data encrypted, or perhaps if you run a government organization as well. Those are the sorts of industries that tend to gravitate towards the salesforce shield solution. So I’m going to close out that help page and I’ll make that available in the resources section of this lecture. And so we’re going to click next here and then remember, this is a Social Security number on a contact record and we’re not going to know Social Security numbers for our regular contacts, but for people that are internal employees. And that would be people that especially don’t have a salesforce account, like non salesforce users.
But there are people that are in house in our own organization. A lot of companies will have corresponding contact records for their own internal people. And so we want to allow for the entry of Social Security numbers in here. And so at least in America, these numbers are nine digits long and then sometimes there’s dashes that appear. So we’re going to allow for a little extra room there in case there’s larger equivalents in other countries.
I don’t know what the maximum length of any possible governmental Identifier is, but for this example we’re just going to put a length of 14 and then we could make this required. But we don’t want to do so on the contact level because as I mentioned earlier, primarily most contacts we’re dealing with are not people that were going to know their social and so this would be only for our internal employees. We don’t want to make this a required field. Then you select a mask type here and so here’s where it gets pretty interesting as it relates to some of the types of encryption you can do there’s. Masking all characters so that they can’t see anything, or you could leave the last four characters clear. And that’s a common example of where you want some level of encryption, but you want your end users to be able to search. Like on the last four of someone’s social, you’ve probably called into a doctor’s office and they’ve asked for the patient’s date of birth. And last four of the social, for instance, to make sure they’re dealing with the right person.
So we’re going to do that for an example. But I’m going to click back in there real quick to show you some of the other mask types is credit card numbers, national Insurance number, Social Security number and Social Insurance number. So I’m just going to say last four characters clear though for this example. And then the mask character you can do Asterisk or X’s and that’s just the visual for what you would prefer to display. And here’s an example then of the last four characters clear. So let’s look at some samples of some of these others then such a Social Security number, it gives it in a Social Security number format with the three characters, then the dash, then two characters, then a dash, and then the final four numbers actually like that better for our scenario.
So I’m going to go with that actually and click Next. Let’s make this read only for most users and only editable by system administrators. And so you notice in most of our examples previously, we’ve been dealing with system administrator, which is a standard profile and then the custom marketing profile. So we’ve got a fictional additional user in our instance named, I believe, Jim, or John Doe, and he’s assigned to this marketing profile, so he’s able to read the Social Security numbers for end users. But myself, as an admin, I would be able to edit those and make changes.
So if I click Next and then add this field to the page layouts for the contact object, I now have added a Social Security number to this object and to the corresponding page layout. So now if I go to Contacts and I pull up Arthur Song and I go to the Details tab, and then once again, I’m going to go ahead and search for that field and I’m not finding it. So that tells me I need to refresh because we’re in Lighting Experience. Now if I search for it, I pull up the field and see it highlighted here. So I’m going to enter in a fictional Social Security number of zero and click Save. And hopefully that’s no one’s legit social. That would be really odd if it was.
So now the user experience is, it appears encrypted for me as a system administrator. So if I click Edit, it keeps those first five characters encrypted, and I only can see the last four, so I could make a change to the whole thing here. So if I want to do one, one one and click Save, then it makes the update accordingly. So you can see there’s a lot of mask options for creating encryption, and there’s also different levels of encryption salesforce. Shield provides 256 bit encryption, but the standard encryption out of the box that’s supported through this field type is 128. So Next, now that we know how to create encrypted fields, we’re next.
- Roll Up Summary Fields
So now we’re going to create a roll up summary field and I’m going to do that in our example on the Account object. So if you notice, I’m in the Object Manager already and I’m going to click on the Account object and then go to Fields and Relationships and then I’m going to click New to create a new field. And under the field type I’m going to select Roll up Summary. Now this description here is a good one. It says that the rollup summary field is a read only field that displays the sum minimum or maximum value of a field in a related list or the record count of all records listed in a related list. And so we’re trying to get some sort of roll up of related records to go up to the account level. And so in our example, we’re going to pull in some numbers related to opportunities that are related to an account. So I’m going to click next. And then for the field label I want to display on the account the number of total open opportunities that belong to an account.
So I’ve added a description to remind myself what this field is for and it’s a roll up summary field that displays the total number of open opportunities for an account. So clicking Next I now come to this special step in this wizard that looks different than most others and that’s because we’re creating a roll up summary field. So we select the object to summarize. So in the summarized object drop down it will be any related objects that relate to the Account object and that would be specifically any that are in a master detail relationship. And so opportunities are the detail to the master which would be Account. Or think of it as child and parent. You’ve got to have the parent account before you can have any child opportunities. And so the different roll up types available here are the count. That’s the sheer number of open opportunities which is what we actually want. But some of these other options are to give you a sum where you can grab a field to aggregate. So you could count up the sum total of the various different number or percentage fields. So you could pull in either discount or probability or quantity or you could select a minimum and the field to aggregate would be any of these here or a maximum which are the same for the men.
And so that just pulls up the lowest value or the highest number value and the sum gives you a total. And so we want to go with count though, we just want the number of open opportunities. So I’m going to specify a certain criteria though. I don’t want all opportunities, but just those that are currently open that belong to this account. So I’m going to select closed equals false and then click next. And then I want to leave all of these defaults selected so it is visible to certain profiles and it’s read only to all because this is a display only field. So even if some of these profiles could indeed see this value that’s going to be in this field, it would only be read only because it’s a display field. So they all are checked by default on the right. So clicking next, I now need to add this roll up summary field to my page layouts for the account objects, I click Save. And so now I’m going to go to an account and I’m going to select United Oil and Gas Corp. And so we’ve got our related list here for our opportunities and it says six plus.
And so that also just lists all opportunities, not those that have been closed as either one or lost. This one has been closed one, this one’s been closed one, this one is still open because it’s in Proposal Price quote stage and then this one is closed one, and this one is closed one, and this one is under Needs Analysis. So there’s only two open opportunities that I see. There may be others once I click on View All here’s all the opportunities. So as you can tell at the account level, it’s hard to tell how many open opportunities this account has. And even in this list view I can’t tell readily which ones are open or which ones are closed. And so I’m going to go back to the account level and then I’m going to look in the Details tab because the Details tab will be where this roll up summary field that I just created resides and that’s if it actually displays without me having to refresh and it is there. And so I’ve got a total of four open opportunities for this account.
So you can see the value and be able to do roll up summary fields on an object because it can give you better visibility and data and that way you can see things at a glance from a list view, for example, or in reports. So one thing I want to discuss or bring to your attention before we go into further types of roll up summary fields is the online help page for this particular field type, which is the roll up Summary. This documentation is very helpful in understanding the nuances of what can and can’t be made as far as roll up summaries and also provides you with implementation tips. And so the explanation here is a good one as far as what a roll up summary even is, such as it calculates values from related records such as those in a related list. So you can create a roll up summary field to display a value in a Master record based on the values of fields in a Detail record. So if you just remember, a Master Record is parent and then Detail Record is child.
And so any child objects roll up to the parent or any detail records roll up to the master and then the detail record must be related to the master through a master detail relationship. And we just not too long ago created a master detail relationship, if you recall. And for example, you want to display the sum of invoice amounts for all related invoice custom object records in an account invoices related list. You can display this total in a custom account field called total invoice amount and then as well you can perform different types of calculations with the roll up summary field. So we did do the example of counting the number of actual records in a related list when we did the total number of open opportunities. And if you notice we did criteria to just specify those that were still open but you can also calculate the sum, the minimum value or maximum value of a field in the detailed records. So then some of the caveats here that you need to become familiar with, especially for the exam is what you can and can’t do as far as creating roll up summary fields.
So you can create roll up summary fields on any custom object that is on the master side of a master detail relationship and then any standard object that’s on the master side of a master detail relationship with a custom object. So one thing to bear in mind is that you cannot do roll up summary fields for the most part between two standard objects. The common use case is that the standard object is the master and that the custom object is the detail record. But then you can do roll up summary fields between two custom objects. Just one needs to be the master and one needs to be the detail and they have got to be in a master detail relationship.
So you notice here that when it’s talking about standard objects it has to be the master and it can only be the master in a master detail relationship with a custom object when you’re doing a roll up summary field. But the one exception to that is the one that I just did in the previous example in this lecture and that’s accounts using the values of related opportunities. And so we did leverage opportunities and we did a roll up summary field counting the number of open opportunities that belong to the account. So the account is the master and opportunities the details. So that is an example of two standard objects that allow a roll up summary field. But for the most part, if you have a question on the exam about need to do a roll up summary field, if they’re trying to get you to have the custom object be the parent or the master and then a standard object being the detail, you know you can’t do that because that’s upside down.
The standard object has to be the parent and the custom object has to be the child. So then there’s some other caveats here and this goes into a lot of depth as far as the ins and outs of roll up summary fields. And then there’s things here about the filters and formula fields and a lot of additional information that you may want to explore. And then other things to keep in mind is that calculating roll up summary field values can take up to 30 minutes depending on the number of records affected and other factors. So it’s not necessarily an immediate thing. And there’s also notes around multiple currencies which we dealt with earlier, so be sure you check that out as well. Roll up summary fields are very powerful field types that you can leverage, but as well there’s limits to how many you can do on an object. And so I believe that value is ten and so you want to use those sparingly.
And there’s also limits on the number of roll up summary fields you can create on an object. And so sometimes if you’re installing apps off the App Exchange, those apps may create additional roll up summary fields on an object and you can reach limits very quickly. So you want to be sure and follow even these best practices that are in this help section as well. And so the main things to bear in mind though, as it relates to the exam and just wrap your mind around what roll up summary fields are.
And what they do is that they can provide a sum, a min, a max or a record count and that you can do a roll up summary field between any custom objects that are in a master detail relationship or between standard and custom objects as long as the standard object is the master and the custom object is the detail. So now that we have brushed the surface of roll up summary fields, the next lecture, I’m going to go into one of the sample exam questions from the study guide and that’s exam question number four where we have a scenario that has to do with fixed company needing to create a roll up summary field. So let’s next look at that and figure out how to.
- Sample Exam Question #4 from Exam Guide
Now it’s time for us to look at another sample exam question from the study guide. This would be sample exam question number four. Specifically, if you read the scenario, it says that universal containers need to create a roll up summary field on a custom object that counts the number of related records on another custom object. What type of field must exist before the rollup summary can be created and where should it be located? Located? So you need to choose an answer here. And so reading along option A would be that we would need a lookup relationship filled on the parent object. Option B would be a lookup relationship filled on the child object. Option C would be a master detail relationship field on the parent object. And then option D would be a master detail relationship field on the child object. And so this is kind of a twostep scenario here where ultimately universal containers is needing to create a roll up summary field on a custom object. And they’re telling you what that custom object does, it counts the number of related records on another custom object.
And if you recall in the previous lecture, we did just that, but we did it on accounts related to opportunities. So that was two standard objects which the only way you can do a roll up summary on two standard objects is between accounts and opportunities. Otherwise it needs to be between two custom objects or a standard object being the master side of the equation and a custom object being the detail side. And so they’re asking then in the second part of this scenario, what type of field must exist before the roll up summary can be created and where should it be located? And so as you approach these different answers or potential answers, you can see how you can easily get confused between the four. At first blush you might think that all four of these could be right. And if you recall from the previous lecture though, that one of the caveats around creating a roll up summary field is that it has to be in a master detail relationship. The two objects have to have a master detail relationship established prior to creating a roll up summary field. And so that automatically rules out A and B as potential correct answers. It cannot be A and it cannot be B because it’s saying that you need to first create a lookup relationship on either the parent or the child object.
And so you rule those out and as you’re taking the exam, then you’ve got a 50 50 shot now of getting this right. You know, it’s either C or D and then you notice what’s the difference between these two. They’re both a master detail relationship field, but one is on the parent and one is on the child. And so it’s asking as far as the where should it be located? It says what type of field must exist before the roll up summary can be created and where should it be located. So if you hearken back to when we created the roll up summary on the account and we were counting the number of open opportunities, then you realize that the Master detail relationship is between the account and the opportunity and the child side of that is where the Master detail relationship is established. And so you don’t establish a Master Detail relationship field on the parent object.
It doesn’t work from the top down, but you go from the bottom up, you go from child up to parent and so you create the Master Detail relationship field on the child object. And so for example, we’re on the United Oil and Gas Corp. Account again and we’ve got our total of four open opportunities. We created the roll up summary field on the parent but it is looking at and it’s totaling up the total number of open child records. And so this Master Detail relationship is established on the child level. So let’s exemplify this further by looking in the Schema Builder. I click on set up home and search for Schema.
If you recall, we’ve got our different objects that we’ve created for our application that we’re building, which is the IMDb clone app. And so we have a Master Detail relationship now between the Episode object and the production object. So let’s go into the Episode object in setup then and look at this further. So if we go to the Object Manager and click on Episode and then we go to the Fields and Relationships section for episodes, we see we have this field label for TV show which is a Master Detail relationship to the production object. Let’s go to the production object and let’s create a roll up summary field next so that this will make more sense. I previously did the Account and opportunities scenario which is two standard objects which is more of an exception than the rule. So I want to go now to two custom objects like we talked about before in our sample exam question.
And so I want to go to the production object which is the parent or the master in the Master detail relationship between the production and the episodes objects. And so now I want to create a new roll up summary field and this will be between two custom objects and this will be the number of episodes. And so then I’m going to click next and then I am going to do a summarized object. The only other object that the Productions object is in a Master detail relationship with is the Episodes object. So I’m going to select episodes and then I’m going to perform a count on the total number of episodes that belong to a TV show by way of this roll up summary field.
And so I could add additional criteria here to only include records meeting a certain criteria. We’ve not created record types yet. If I had created a record type, I could specify record type equals TV show, which we’ll do later. But for now, I’m just going to say all records should be included in the calculation and click Next. And I’m going to accept the defaults here and click Next as well for the visibility and editability of this field, which there’s no editability because it’s a roll up summary field and I’m going to add it to the production layout. And so now if I were to go to a production and right now we just have The Wizard of Oz, so let’s create a new production. First I’m going to say the TV show Cheers, for instance, and I don’t know what year this came out, so I’m going to say 1979 as a total guess and leaves the rest blank and click save to quickly create a production for the TV show Cheers. So now I don’t have a related list displayed for episodes.
So what I’m going to do until I get this page layout updated to include a related list for episodes, I’m going to click on the tab for episodes and add it here. So I’m going to click New for a new episode and this would be the child record. And so this would be the pilot episode for season one of Cheers. And so I’m going to search productions and select Cheers and click Save. So now I’m on the pilot episode for Cheers. And so I could click on Cheers here to go to that TV show. And the roll up summary field has a number of episodes of one. So then if I wanted to, I could add additional episodes and the roll up summary will sum those accordingly. So let’s say that the second episode, I have no idea what it would be called, but let’s say that Sam Meets Diane, for example, and I am showing my age here by referencing an old TV show here, but old is relative.
At least I’m not referencing Andy Griffiths show, which is a classic. So now we’ve added an additional episode that is also in season one called Sam Meets Diane. So if I go back to the Cheers TV show, we see that the number of episodes equals two. And so revisiting this question, then we’ve done the scenario now and exemplified this as far as creating a roll up summary fill between two custom objects that are in a master detail relationship. And so that master detail relationship filled has to be on the child object. And so if we go back to our episodes, this is the child object and the master detail relationship with productions.
And so we’ve got a couple of episodes now and those are being counted and tabulated and totaled on the production custom object, which is the parent or the master. So roll up summary fields, they can do a lot. And now that you know how to approach this particular type of question. You can see the scenario driven nature of these questions and how a lot of times there’s multiple parts to this and you could get fixated on the first part, but you really need to fixate as well. Or additionally on the second part because the question that it’s asking is where must this exist before the roll up summary can be created? And so you don’t want to get lost in these long scenarios. Here we’ll be touching on some of these other exam sample questions from the study guide later in the course when it makes sense to address them. But next we’re going to get into something a little more involved with these different field types and that would be considerations when changing a field.