Practice Exams:

Salesforce Certified Platform App Builder – 5 – Business Logic and Process Automation Part 4

  1. Creating Cross Object Formula Fields

Okay, so now we’re going to discuss the Cross Object Formula field. And I mentioned in the previous lecture at the end that we’re going to be doing this particular formula. And this is on that first page of this examples of advanced formula fields and that’s available via download in the resources section of this lecture. And this cross object formula is on the contact object. It mentions here that you can reference this Account Rating formula field from the Contact object using Cross Object formula. So I’m going to copy this. Then we’re going to go back to our salesforce instance. I’m going to go to Setup and go back to the Object Manager. But now instead of going to the account like we were before, I’m going to go to the Contact Object. So if I go to Objects and Fields and Object Manager, we’re going to create a cross object formula on the Contact object.

So I’m going to click Contact and then for Fields and Relationships, once that fills in, this number will pop up. Sometimes it takes a while, lightning is not lightning fast sometimes frankly. So Fields and Relationships and then new for a new field. And this will be a custom field with a formula for the data type. So clicking formula and then clicking next. And so if we refer back to our reference point here in our document, I think we’ll call this Account Rating as well. This is on the Contact object though. So I’m going to do Account Rating and tab over to fill in the field name. And then we want a return type for the formula of text. And then clicking Next to go to the next step in this page I’m going to paste in my formula. And so if we were to click the insert field, you can see you can go up from the contact to the associated account. And then for example, here’s the account name for the account that this contact belongs to.

So if I insert that, I’ve just inserted account name. So across Object formula it can go up to the parent level and then you can pull in a field from the parent level and represent it on the child level. So this is the one I just inserted that I’m going to get rid of because in our example from our document, we’re wanting to pull in this custom field that we created called Account Rating underscore C and that’s on the account. And so what happens with this new Contact Formula field is it looks up to the account and then it looks to that particular field and returns the value of that field on the contact level. So I’m going to check the syntax and there’s no syntax errors in the merged field. I’m going to treat the blank field as a blank and click Next. And then I’m going to take the defaults here by clicking Next and then Save.

So for example, on our account of ABC Corp. I don’t recall who any contacts are that belong to that particular account. But to round this out, you remember that we’ve got our account rating on the Details tab of the account and it had a rating of Red. I wanted to verify what it was to show you when we go to a contact on this account that it should reflect Red as well. And so if we click on the Related tab, the way to get to Related lists or Related records enlightening experiences through the Related tab instead of the Details tab. And if we scroll down, we see that we have no contacts associated with this account. So I’m going to click this get more contacts button for data. We’ve not associated this account with Data. com, and I’m not going to go through the process of doing that now.

But I wanted to show you what that button was, at least that has to do with Data. com, which you can add or clean the account using Data. com Prospector or Clean to get related contacts. And so that goes beyond the scope of this particular lecture. But what we can do then instead of using Data. com is we click on New to add a new contact record. Now we’ve got our three different record types. We did this not too long ago in a previous lecture. And so this contact could be their customer, an internal employee or partner. We’re going to do the default of customer and click Next. And then for this contact record, I’m going to enter in a name for this new contact. I’m just going to call this person New Contact and it’s associated already with the ABC Corp. I’m going to click save.

In order to save this New contact record, it says the New contact was created and the name is New Contact. And so if you want to go to that contact record, you can just simply click on this link here from the Related list on the account. So now in the contact record, if you remember, we created a cross object formula. So if I go to the Details tab and we scroll down, you see now that we have the Account rating field, this is the cross object formula that we created on the contact that pulls in the value from the field on the account. So that’s a really good example here in this document of a cross object formula field. And so next, now that we’ve discussed a lot about formula fields, we’re going to look at an exam question from the exam guide, and that is exam question number two. So stay tuned for the next lecture when we walk through that sample question and we’ll discuss formula fields more, more in depth.

  1. Formula Field Sample Exam Question #2 from the Exam Guide

So now we’re going to round out your understanding of formula fields by looking at a sample exam question from the Exam guide. And as a reminder, this exam guide is available from the Resources section of Lecture One of this course. You can also find it by Googling for the Platform App Builder Exam Guide. And we’re looking at sample exam question number two because it deals with a very simple similar scenario to what we just work through. So I’m going to read this question here and it’s divided into two parts. And then as well, we’ve got to choose two answers. So this is a really good sample question. This will help us unpack a lot of different nuances as far as how to approach these questions, as well as how to understand how formulas work better.

So Universal Containers App Builder needs to display an Account’s Rating on all contacts related to that account. Which formula is valid in a text formula field on the contact to display the appropriate value. Now you’re tasked with choosing two answers. And so one brief note is that when you’re having to select two correct answers, if you only get one of the answers correct, you do not receive partial credit on the exam. You miss the entire question. So no partial credit on your answers. So between these answers, there’s a couple here at the top that are very similar and these are case statements. And one has just the values. And basically this is saying that the Account Rating is hot, then make the contact rating hot. If it’s warm, make the contact rating warm, cold, cold.

And then if all else would be not rated. And then this other one, the only difference is it has quotes surrounding these values as well. It’s the same sort of logic that it’s looking up from the contact up to the account with this dot notation. And it’s saying that if the Account rating equals hot, then put the text value hot in the rating field on the contact. And then the same for warm and cold. And then all else would be not rated and this would be a case statement. So that’s a case function in the formula. These other two answers are very similar as well. They have this notation for Account Rating and the other one is wrapped in text. It’s text account rating. Now you notice here that this field on the account called Rating, that is not a custom field.

Not to be confused with what we just work through, we created an Account Rating custom field. And you notice here is that API name of account underscore rating underscore underscore C. Now, in our example here in this question, it’s account rating. That hints at that being a standard field because there’s no underscore underscore C. So if we go back to the object Manager, we need to actually go to the account object because we’re looking for the rating field on the account. So if I go to Fields and Relationships on the Account Object, we have our Account Rating custom field that we created previously. But if you scroll down and you click on View All and then one thing that’s not great about lighting experiences, when you click View All, it doesn’t actually show you all fields.

You’ve got to click next to go through the next page. And so this is the field that we’re referring to in the sample exam question. It’s just called rating. It is a standard Pick list field. So you’ve got to know enough about the platform to know that on the Account object there’s a standard field called Rating and that it is a field type of Pick list. Okay, so if I click on this, you see that the values in the Rating Standard field are hot, warm or cold. If you remember in our example that we started with, from that PDF, they started off with hot, warm and cold. And I changed that to green, yellow and red. So if we go back to our question, you see it’s Account Rating and that would be this field here. And so one thing to specify here is that this field that we’re leveraging on the Account object looking up to the account from the contact in our formula is a Picklist field.

And so the idea behind returning a text value is you need to actually wrap that return type with a text function. And so what I’m going to do is I’m going to show you how this is correct by copying this. And then we’ll go back to the contact object in the Object Manager and then we’re going to click Fields and Relationships. And so now if we go back to our Account Rating field so what I want to do is instead of pulling from this account underscore Rating, underscore C Field, which is that custom field on Account, I want to change this to pull from the standard field called Rating. So what I want to do is I’ll go ahead and paste in the new value and that’s pulled from the exam guide and it’s Text. And then in the parenthetical is the dot notation of Account Rating.

And so as a reminder, this is going from the contact looking up to the account and pulling in that Accounts Rating that this contact belongs to. And so as well, you can look up the function here for reference by clicking on it and it shows you text. And then in the parenthetical as a value, it converts a value to text using Standard display format. So if we check the syntax, there’s no errors here. So we’ll go ahead and click Save. And so now if we go to a contact record such as Phyllis Cotton here, and we go to the Details tab, let’s go ahead and click Refresh.

And then click the Details tab, we see that the Account Rating field is blank. So what we’ll do is we’ll go to the account that she belongs to and we’ll go to the Details tab there and we will double click on the rating field here to populate a value on the account level and we’ll give this Abbott insurance a value of Hot and click Save. And then if we then want to revisit the contact record we can go to the Related tab for the account and scroll down and go to Phyllis Cotton in the Contacts related list clicking on her record. And then going to the Details tab we see now an account rating of Hot. That is the formula field pulling in from the standard rating value on the account. And so you notice as well a couple of other things to note is when you’ve got to choose two answers and if you see two groupings that are very similar and they may be spread apart or interspersed, but you notice that one of these two is probably going to be right and one of these two is probably going to be right.

So the main other thing to realize is that for these case statements in the sample exam question, the text needs to be wrapped in quotes as well. Now what I’m going to do is I’m going to go ahead and copy this and I’m going to go back to my formula editor in the custom formula field on Contact. So this is the account rating field on the object of contact. So I’m going to click on that, I’m going to revisit my formula and see if there’s another way of forming this to return what I want. So I’m going to click edit. And one brief note as well is that that example PDF of example Advanced Formulas is also available by clicking the more examples link right here in the formula editor that brings up that PDF that we well it’s actually in a different format. It’s the same content as in the PDF but it’s in the online help.

So this is the examples of advanced formula fields and there’s clickable links for these different samples such as date formulas, case management, account management, et cetera. So I wanted to show you how to get to that. So the other correct answer for this question would be this one. And so that’s a case statement. If we look at the function here and the help on that, it says that there’s an expression and then if the value is this, the result is that. If the value is this, the result is this result too, then for all others is the final else result. So that checks an expression against a series of values. If the expression compares equal to any value, the corresponding result is returned. If it is not equal to any of the values, that else result is returned. So we’ll get rid of our text function and we’ll just leave this here and we see that we’re looking up to the account and the standard field of rating through our dot notation of Account rating. And so the first value is hot.

So if on the account the rating is hot, then the Contacts rating will be hot. And then correspondingly, if it’s warm, it’ll be warm, if it’s cold, cold. And if it’s nothing, it’ll say not rated. So you notice now that we have an option to return not rated if it was blank in our previous example, it just would pull in text and then account dot rating. And so when my account had no rating, it was just blank. So this would probably be the best possible answer here, is that for blanks, it’s accounted for that as well with this case statement of returning not rated, but D is also a correct answer as well. And we saw that that worked. So let’s click check syntax and see if this actually works. And it does. And so real quickly, I’m going to get rid of the quotes. I’m not sure what’s going on here with that extra comma. So we check the syntax that should blow up.

And so you notice here, if we compare it to what we had here and I’ll go ahead and I’ll just copy this just to make sure I’ve got this correct for the syntax, there’s no way this can work because it needs the quotes in order to find the different values. And so with the case statement, it needs the quotes to handle text values. And so it’s looking for a field called Hot which does not exist. So to recap here, the possible correct answers are B and D. And then as well, other things to note, as I mentioned, if you have to choose two answers, you cannot get partial credit. And then the word that this whole question hinges on is this word here. It’s a text formula field. It’s returning a type of text. And so with this standard field of rating being a pick list value, it has to be converted to a text value on the contact because it’s a text formula field. And then this other one is this case statement.

This is a great formula because it also returns a not rated if it’s blank. And then as well, since it is a text formula field, we’ve got to know what we’re dealing with. And so if it finds a text of Hot, it returns a text value of Hot, et cetera. And so what I wanted to do as well, I’m going to revert this back to this formula value before we close things out in this lecture and return back and correct this to this formula. Check the syntax again, it should be correct, click save. And now if I go back to this account that I previously was in for Abbott Insurance, I’m going to clear out the rating field. And so instead of a value of Hot, I’m going to select none and click Save. And then I’m going to go back to Phyllis Cotton. And another way you could get to her would be from the Contacts drop down and select her under Recent Records and go to the details. Now, for the Account rating field, it should say Not Rated and that’s because our field is returning not rated for the else in the case statement. That’s a great formula and another good way to start to understand this better.

And so I really do encourage you to explore these sample advanced formula fields and work through some different scenarios to begin to become more familiar with the different functions available to you, the different types of statements and how to form great formulas and cross object formulas, et cetera, because it just might appear on the exam. So keep these tips in mind as you continue onward towards your quest to becoming certified as a platform app builder.

  1. Creating Validation Rules

One thing you’ll definitely encounter on the exam is the concept of validation rules. And so Salesforce provides the capability of creating validation rules at the object level so that when you enter in new account records, for example, you can validate if the data that’s being entered is valid or not and block bad data from entering into Salesforce.

And so if you notice, I’m on the account object in the Object Manager Manager and there’s a link here for validation rules and there’s no validation rules currently on the account object. And so if you were to try to find validation rules via the Quick Find and set up in Lighting Experience, you won’t be able to find that. The main thing to bear in mind is that validation rules are accessed via the object manager at the object level and then you click on validation rules. So in order to create a new validation rule, you simply click on the new button and then I’ve got a sample validation rule that I’m going to paste in and then we’ll talk about it here in a moment.

And so the idea here is that I want to go ahead and paste in this validation rule and then I’ll create the rule name. So what I want you to do is not worry about the meaning of all this right now. If you’re not familiar with validation rules already, this might be intimidating, but this is the same sort of formula editor that we saw previously. But this is used to derive condition formulas for a validation rule. So what we’re doing basically is we’re checking the length of this standard field called account number to see if it’s equal to seven characters or not. We’re going to call this account number length and then you could create a validation rule but not make it active by unchecking this box. I’m going to go ahead and check it so that it’s active and running. You can turn off validation rules if you want to force data in as an admin or a developer and then turn it back on.

You may have an occasion where you need to do that. So you want to give a description to this validation rule so you can remember what it does. It’s hard sometimes to go through and find the validation rule that you’re looking for unless you give it a description. So for the description, I’m saying that this rule forces all account number fields to be exactly seven characters long. So then down here in this condition formula, it’s important that you understand how this works. The main thing to note is if this formula expression is true, then it displays the text defined in the error message area. So if this formula is true, then basically what that means is that there’s an error and it needs to display an error in the interface for the end user.

And so at the first year we have this and function so if I click on and you see that it’s checking these logicals, it checks whether all arguments are true and returns true, if all arguments are true. And so if you remember, we’re looking to see if this formula expression is true and if so, it displays the text defined in the error message area which is down here. And so let’s go ahead and fill in the error message as well and then we will talk some more about this validation rule. So the field that we’re dealing with is called Account number. And remember, the error message is something that end users will see. So we’re going to say account number must be seven characters long. And so then for the error location you could have this appear at the top of the page or you could have it display at the specific field and then you specify the field on the account since we’re dealing with the account object here and we want to specify the account number field.

So now if an account number that is entered by user is less than or greater than seven characters in length, then it’s going to throw this error. Now what’s this is blank about, if we click on is blank, we’re seeing an expression here. It checks whether an expression is blank and returns true or false. So actually I’m going to remove this is blank functionality and this and statement and we’re just going to boil this down to a length of less than or greater than seven characters long. And we’re going to check the syntax and just simplify that formula. I don’t think that’s the greatest example formula, so no errors are found. So I’m going to click save. Now we’re going to go back to Abid Insurance.

We’ve been in that account before and we’re going to test this out and see if this validation rule works or not. If I click on the down arrow and select Avid Insurance and go to the details tab on this account and then I look for the standard field account number. I’m going to enter in an account number and you can double click on any field that shows a pencil icon. I’m going to attempt to just enter six characters and click Save and be sure your validation rule is set to active so that it will block this from entering as a valid data entry point. So you notice our validation rule fired. It caught this and saying review the following errors account Number and so you can see the error message here, if I close that out is saying account number must be seven characters long. So that’s an example of the error message and it’s displayed on the account number field. So as well, if I were to do an eight character attempt, it will also have the validation rule fire. If I attempt to make it blank, it also fires as well. So you see how we took an example and then we changed it to fit our needs.

I did take out this is blank designation. I could see how you might want to allow for blank account numbers because basically now we’ve enforced that a value has to be entered here because no characters is less than seven and so any blank account number fields would block entry through the validation rules. And so you’re going to run into validation rules on the exam. And the main thing is that you want to become familiar with the different types of things you can do with validation rules. And so in these examples of validation rules you can see that this gets into formula functions as well and the formula operators and functions and there’s so many different examples here that I want you to take some time to review these and try some of these out as well. You can do regular expression through this regex designation here and you see a lot of ands and ors and nots for example and so it can get pretty complicated.

And this as well is one of the code like things that you’ll be tasked with doing as a platform app builder. This is not Apex code but it is some pretty advanced formulas. The main things to keep in mind is that with any sort of validation rule you need to enter the name of it, you need to enter a description, you’ll have your formula that it’s looking to evaluate to true. And if it evaluates to true in the validation rule there will be an error message that displays and then you’ve got to specify location and that location can be a specific field or it could be at the top of the page. And so I’m going to scroll through a little more and highlight a few more things that you can do such as billing zip codes. You can enforce either the five character zip code or the nine character for the US format with a dash in between. And then as well that’s also a regular expression.

And so it’s a good idea until you become really advanced in your formula building skills to just pull from example formulas wherever you can because it can get very complex as you can tell here. And so formulas can get really large. And this one here is valid billing state for the United States and verifying that it has a valid two character code for the billing state. And that’s if the billing country is US or USA for example. So this PDF is 35 pages and really just scratches the surface of what you can do with validation rules. And the main thing to keep in mind with validation rules once again is you get to that through setup. I’m going to leave this page here. You get to validation rules in lighting experience from the object manager and going to the specific object that you want to create the validation rule for and the purpose of validation rules are to have good data going into salesforce and enforcing certain types of data. And then as well, we have our one validation rule that we created in this lecture and you can then edit or delete those by clicking the down arrow here.

And then as well, you always want to make sure that your validation rules are active. So definitely a topic that you need to explore further because validation rules will be represented on the exam and you’ll need at least a pretty good understanding of the different formula functions as well. So we’ve been recently dealing with formulas through validation rules and formula fields. It’s a really good idea to become strong on the formula side of things in the Salesforce platform. And so next we’re going to be talking about workflow rules in the next lecture.