Salesforce Certified Platform App Builder – 3 – Data Modeling and Management Part 2
- Creating a Picklist Field
So now it’s time to create a picklist field. And I’m on a campaign for an example and this is just one of the example campaigns that come in your free Salesforce developer account. One thing I want to highlight is these campaign samples that Salesforce provides have just got to be updated. This one is named with the date range of November 12 through 23rd of 2001. And so I’m going to edit this quickly and bring this into a more current status and click Save. And so this lecture as you realize, it’s not about renaming a campaign but it’s about creating a picklist field. And so I wanted to show you an example of a picklist field on a campaign and that would be the Type field. And so I’ve clicked into the Type field and I click this drop down here and this is known as a picklist field in Salesforce. And a picklist allows you to select just one of many options from a drop down.
And so in the next lecture we’ll be dealing with creating a multiple select pick list field. But for now you can only select one of these here. And so if you notice, you’ve got conference, webinar, trade show, et cetera for a campaign record. And so I’m going to find these options lacking because there’s not an option for social. And so let’s say for now though, I’m going to just update this campaign and click Save. And this is more like a placeholder if you will. And that’s the type of updates to banner ads here in this top bar here on the campaign. And then the filter as well reflects banner ads. But let’s say that instead of doing banner ads, I want to signify that this campaign has a type of social. And so I would go into the Object manager and then I would select the campaign standard object and then go to the fields and relationships. And so if you scroll down to the bottom of the list of fields it cuts off right before the Type field displays, there’s this link for View All.
I’m not real fond of this enlightening experience, to be quite frank. I didn’t see Type and I thought that for some reason it was missing. Kind of threw me for a loop there for a second. And then I failed to see the View All filled because it just looks like another field actually rather than an option to view all fields. So clicking on View All brings up hopefully all fields and it doesn’t. So there’s still some work to be done in lighting experience. Obviously. One thing would be if you click on View All it should show View All rather than take you to just the same 20 fields that you were currently seeing and then having to then click on Last in order to see the last of the fields.
And so the last of the fields is the Type field. So we’re finally there and we can click on it to see more details around the type field. And we can see the Pick list values here. I could change these if I wanted and so I’m going to go ahead and edit banner ads to instead be named Social and click Save. Now, if I go back to that campaign, I want to show you an interesting thing here. So in this campaign that I previously selected to do banner ads, now we look at the type and it’s been changed to Social. So on the exam you’ll be asked about implications of changing Picklist values and the impact that that has on existing records. That is definitely a potential question you’ll have. And so if you change a Picklist value in a Picklist field, then all the existing records will be updated to that updated Pick list option. So you notice that instead of the same banner as it now says Social.
So it’s really easy to inadvertently change historical data. And let’s say that in this example we were thinking, well, this is 2016 right now when I’m filming this actually, and you may be watching this in early 2017 or beyond, let’s say that you made a mistake and you changed a Picklist value from banner ads to Social. Now you could go and add an additional Picklist value, but let’s revert this back before adding an additional value for banner ads. What you would do is you would go into the Object Manager and go back to the campaign object in the fields and relationships, and then you would do the annoying view. All that does nothing other than give you the option to click Last, which is what you’re trying to get at. Then click Type and then click Edit next to Social. And let’s revert this back to banner ads so that we then in effect, revert all of those existing records that were changed to Social back to banner ads. You’ll do this kind of stuff as a salesforce developer. You’ll learn from your mistakes and learn to recover. So the main thing is just to keep your head about you and not make things worse by just rushing and trying to do a quick fix. So now we’ve got our banner ads back in place. So if we pull up that campaign again and go to the Detail screen, it should be back to banner ads.
So all of our banner ads designations on campaigns are there. So now if we go back to the Object Manager for the campaigns and we’re back on the Type Picklist field, I want to add a new Picklist value. And so now we want to add Social and click Save. And so let’s see if we can see that now as an option in the Picklist field if we go back to this campaign once again and go to the Details tab and we click on the pencil icon for the Type Picklist field. Currently it’s set to banner ads.
So now we’re going to scroll down and you’ll find the new picklist value for Social down at the bottom. You may have an issue with your browser if you don’t see it, where it still retain the old values and cache. And that seems to be an issue with Lighting. Experience as well, is that sometimes you make changes and they just don’t appear. And so if you’ve not seen Social, if you’ve been following along with me, you may need to just refresh your browser or even go to the links of Reverting back to Classic and then back to Lighting and Experience and you should see Social.
So clicking social and clicking save. We’ve now updated and added additional picklist values and also addressed the implications of changing the options for the available pick list values in a picklist field and those impacts on existing data in your own salesforce organization. And so now we’re going to create an additional picklist field to show you how to create one new. So if I go to the Setup menu and go to the Object Manager, I can hop there by just clicking Get Started under Explore Objects. For instance, if I go to the campaign, the thing to bear in mind when you’re dealing with picklist is that you can only select one option out of many. And so to create a new field I click New here I select the Pick list option and click Next. Now I need to give this picklist field a field label.
So in my example I am creating a pick list field to where I’m going to specify a primary age target. And this would have to do with campaigns and demographics. A lot of times when there’s a campaign a certain age group or age bracket is targeted. And so in this example, I’m going to enter values with each value separated by a new line. We’re going to say that the options are less than 18 years of age and then 18 to 24, 25 to 39, 40 to 55, 56 to 65, and then we’ll do greater than 65 years of age. There’s other options here where you can sort values alphabetically that doesn’t really apply because we’re dealing with numbers. You could use the first value as the default value mean when you create a new campaign it would default to this first option here of less than 18.
We’re not going to do that. And then you can restrict the picklist to the values defined in the value set. Now what that means is you can enforce data integrity with restricted picklists by leaving this checked. This setting limits the field to accept only values from your pick list even if the field is updated through the API. So with the pick list there’s no way for someone to hard code in a number that’s not supported or a value that’s not supporting the pick list. But if you have this unchecked and someone does a data import through the Data Import Wizard or through the Data loader, they could put in Gibberish here and it kind of mess up your data. And so it’s usually a good idea to restrict the Picklist value. And so now you can enter a description and help text if you wish. You can also make this a required field, which I’m going to leave that blank and click Next. And then I’m going to accept the defaults for the Visibility per profile and make this an Editable field by leaving the Read only checkbox unchecked and then click Next. And then I’m going to add this new field to the campaign layout. So now if we revisit this campaign and go to the Details tab, you see here that you can’t see the new field. We saw this phenomenon earlier in Lighting Experience and that’s because there’s no value already entered. But if I click Edit by clicking the down arrow and selecting Edit.
So when I click Edit and scroll down, I’ll see the new field here for the Primary Age target. So if I click the down arrow here and select the primary age for this campaign and let’s say I’m targeting individuals that are the age of 25 to 39 and click Save, we will see this detail page refresh once it’s done saving and it’ll show the value of that primary age target. So now that you’re familiar with creating a Picklist field, we’re going to create one more, but we’re going to do it for our IMDb clone app. And so we’re going to go to the Object Manager again. And we previously dealt briefly with the Production Position object. If I go to the Object Manager and select the Production Position object, and we did this earlier when we set the Name field to be Auto number.
So if you go to Fields and Relationships and you see the production position name field and the data type of Auto number, and when we created a record, it just automatically numbered that and there were no other fields to make that screen have any editable fields. We’re now going to create one and we’re going to call this particular field a Position type. And this will be a Picklist field that we’re creating. So clicking new will enter the label as position type. Once we select the Picklist option and then clicking Next, we specify the label. And as I mentioned, the label will be position type. And if you recall, we’re on the Production Position object. We will flesh out this object a lot more in future lectures. But for now, we’re just adding a field to the Production Position object. We’re not going to use global Picklist value sets and if we tried to, we couldn’t at this point because there’s none that have been set up that is set up before you can use a global Picklist value, you’ve got to specify that. And so we’re going to enter the values with each value separated by new line.
And so as I start to type these, you may begin to realize what the position type is about. This is the type of position that a person fulfills on a production. And so the production position object will record the position that someone fulfills on a production. So therefore this production position object will be a junction object. Now it’ll be later on in this course we have lectures related to create an adjunction object. And this production position object will be one that will serve as a junction object. And what a junction object is, is it establishes a mini to many relationship. That is something that will definitely be on the exam and you need to understand junction objects in salesforce and how that occurs. And so as this relates right now to creating this picklist value, I want you to begin to visualize that you’re dealing with productions and there’s people that are associated with those productions and they hold a position. And so when we’re dealing with the production position, we’ll have a master detail relationship with both the production object and the person object.
And so that may be blowing your mind or you may be tracking right along with me. Either way it’s fine. But I wanted to at least answer the questions you may have like okay, what is this object? Why are we doing this? How does this relate? Why should I care? So this is giving you a glimpse of what is yet to come. And so for now, we’re going to finish out this lecture for creating a pick list by specifying these position types. So I’ve got actor, cinematographer, composer, I’m going to add to that director, lighting, makeup, artist, musician, producer, sound, mixing and writer. And feel free to not put in that many. You can just put in a few if you’d like. And then I’m going to sort these values alphabetically and that way they will display alphabetically automatically.
Even though I did enter those in alphabetically, it’s a good idea to check that. If you do want those to be alphabetized, just make sure you’ve not miss sorted those upon entry. You can leave the rest the default and let’s click next and then next to keep the defaults and then finally save. And so now if I revisit the production position object and you see this previously created production position one record. And so now we have an editable field on here and we can select what position that this person would hold. Now we’ve not created the master detail relationships yet to the person or the production. So we will be filling this out more fully later. But for now, we’ve just created the position type pick list or click can save.
- Creating a Multi-Select Picklist Field
So now we’re going to get into creating a multi select picklist. And if you recall in a previous lecture we changed this picklist for type on a campaign to include social as one of the picklist options. And so previously we had banner ads and then we changed that to social. We reverted it back and then we finally added social as its own picklist value. So now what we want to do is we want to add a multiple select pick list. The idea behind this multiple select pick list is we want to be able to specify which social networks this campaign is going to be using because it may use Facebook, it may use Instagram, it may use Twitter, it may use any combination of the above. So we want to be able to give the user the ability to specify which particular social networks this campaign is going to be used on. So to create a multiple select pick list, we want to go to the Object Manager.
And so I’m going to click get started under the Explore objects option here. I’m just doing it different ways to show you and remind you of different ways to get to the same place. And then we want to go to the campaign standard object and now clicking on Fields and Relationships. That takes us to the Fields and Relationships section of this object. And we can click New to create a new field. And remember, we’re creating a multiple select pick list. So the option here that we want to choose is called Picklist and then multi select in parentheses. And this allows users to select multiple values from a list you defined. We scroll down and click Next. I want this to be clear to the user that these are the different social networks that they’ll be using. So if they select a type of social in the type field, then we want this other field to display options for social network.
And the way that we’re going to do that has to do with field dependency, which is in a later lecture. But I want to give you a glimpse of what lies ahead. The next lecture is creating a dependent picklist where we’ll make this more dynamic. But for now we’re just wanting to fill in the values of this actual multi select picklist field. So we don’t want to use a global picklist value set. We want to enter the values ourselves. And so I want to enter Facebook, Twitter, Snapchat and Instagram. Now you could add or remove these if you wish, and I’m going to go ahead and sort these alphabetically. I’m not going to specify a default value by selecting the first one as the default value, although you could. I’m going to uncheck this so that if I import something that’s using some other social network, it will allow that to happen. If I were to restrict this, then if I were to try to import campaigns through, like the data loader for instance, if there was a value other than one of these that I’ve predefined, it would error out and not allow for other entries. And as you know, social networks come and go.
And recently it was announced that vine is going to be coming to an end soon and it seems like the Google Plus is on the long march towards death. You may remember MySpace being large not too long ago, but now it’s not really in use. But those would be examples of social networks that you may have used a long time ago. And if you’re wanting to import those legacy records into salesforce, you want to allow for that. But you don’t want these to be current options that a user can select now. So you would want to uncheck this to not restrict the picklist values to just the defined values in the value set. And so now we allow for people to be able to import old values from the user interface. They can only select one of these four.
So I want to make the visible lines four and this field name has got the underscore for the API name. I don’t want to make this required because this is going to be dependent in the next lecture on the user selecting social from the type pick list. And so we’re just going to click Next and we’re going to accept the defaults here for the visibility per profile and making it editable by leaving the read only column unchecked and clicking Next and adding this to the campaign page layout and click Save. And so if we revisit a previously accessed campaign such as this DM campaign, and we go to details, we’ve got our type filled and it is set to social and then let’s see if we can find our social network. Okay, I’m not seeing it. Let me do a search in my browser and it’s not finding it.
So let me refresh my browser and this will take me back to the campaign. But refreshing, the browser should show the field, I hope. So if we go back to details and let’s scroll down a little bit, usually new fields are towards the bottom. I previously specified that I want to add it to the page that let me do a search again. And there it is down at the bottom. I just didn’t see it. It was actually down below description. So I’m going to click on this, I’m going to select Facebook and then remember this is a multiple select pick list and so we can select more than one. So the pick list just allows for one. The multi select allows for multiples.
So you can command click to just select the ones that you want and then click Save. And so for this particular campaign, you notice that we’re going to be using for our social networks facebook, Instagram and Snapchat. And so now in the next lecture. We’re going to show you how to create a dependent pick list so that these values are only selectable as long as the type on a campaign has been set to social. So stay tuned as we continue on in creating a dependent pick list in the next.
- Creating a Dependent Picklist
So now we want to create a dependent pick list. As we mentioned previously, we’ve got a campaign with a type of social and the social networks have been specified. Our Facebook, Instagram and Snapchat, you notice these are separated by semicolon. That’s how salesforce separates multiple selections in the background. And so if you’re loading data, for instance via the data loader and you want multiple selections to flow into multi select pick list, you want to separate those values with a semicolon. So the way to make this a field dependency so that the type field and the social network field are both tied together, is through creating a field dependency. So if I click the setup icon and go to Set Up Home and then select the Campaign object and then selecting the Campaign object, we go then to the fields and relationships.
Up until this point, anytime we’ve needed to create a new field, we just click the New button and we’ve not drawn any attention to the field dependencies button yet. And now it’s time to do just that. So we’re wanting to tie in the type field and a social network field together. So we’re going to click Fill dependencies. There’s no field dependencies by default on the campaign out of the box. And now we’re going to define dependencies between fields by clicking New. And so here we’re going to specify a controlling field and a dependent field. And so if you recall, the type field is what we want to drive the dynamic nature of the social network field.
So that if the type field has social selected then we want the social network field to come alive and allow for further selections. You can read these instructions to give you further details on how this works and all the ins and outs and limits for example. But I’m just going to click Continue and keep things semi straightforward. So now we have this grid based view. So for this field dependency, the controlling field is the type and the dependent field is social network. And so for these values and the social network field, we can either make individual options available or not based on the type that’s selected. And so we’ve got the first few here for conference webinar Trade Show public Relations and Partners.
I don’t want the social network field to become live unless the type that’s selected is social. So I’m going to click Next to go through the next five options for type which are Referral, Program, Advertisement, Banner Ads, Direct, Mail and Email and then I could click Next to see the final three. Or if you want to see all, you can click View All. This doesn’t work so well in Lightning Experience. To view all because there’s no horizontal scroll here at the bottom to help me get all the way to the right to see social. So I’m going to view in sets of five by clicking that and then going next and then next to see social. So finally I can click on these to select what I want to come available.
If the type is social and then click Include values, you notice that those colors change to yellow and so these are now included so that if social is selected then the included options in the multiple select picklist are all four for social network. Now that’s all I want to do at this point but you could do additional includes or excludes and be really granular. But when you’re done with your includes and excludes you just click save and it’s saying that there’s twelve controlling fields with no dependent values save. Anyway, what that has to do with is these other types.
I don’t want social network going live so that’s fine. So I’m just going to click OK to confirm. And now we have our field dependency between type being the controlling field and social network being the dependent field. So if I go back to our campaign let’s actually do a new campaign because this will be easier to show how this works in action. So I’m going to say example social my type I’m just going to leave that the default of conference and it’s if you notice social network has no options and it’s grayed out and so if I change the type then to social this comes alive and it allows me to do multiple selections. So I’m going to click save. And so now I’ve got a new campaign called Example Social and it has a type of social and the social networks that have been specified are here at the.