Salesforce Certified Platform App Builder – 3 – Data Modeling and Management Part 5
- Considerations When Changing a Field’s Type
Let’s chat for a few moments about considerations when changing custom field types. This is going to be more of a conceptual talk than a demo and that’s because you need to understand some underlying concepts around implications and what might happen inadvertently when you change a custom field type. And so what I mean by that is that we’re talking about changing the type of field a custom field is. And so in this example, I’m on the Campaign Object and I’m in Salesforce Classic right now because I feel like it’s easier to see all the different fields and we’ve got the standard fields up here at the top and then the custom fields down here at the bottom. And so one example I could potentially do, but can’t because it’s a standard field, would be to convert this type picklist field to a multi select pick list. I can’t do that because it is a standard field and so therefore you cannot change field types on standard fields. These cannot be changed. Important point to make here. But as far as these custom fields, you can change the data types or field types. Those terms are used interchangeably. You can change those, but if you do so, you’re in danger of losing data.
There’s times that you will and times that you won’t, and there’s so many different caveats to keep in mind that I just want to encourage you highly to become intimately familiar with all the ins and outs of this. By reviewing this particular help topic called Notes on Changing Custom Field Types, which I will make available in the Resources section of this lecture. And so there are several considerations that you need to take into account before converting fields and saying to only convert custom fields for which no data exists or you will risk losing your data. Changing the data type of an existing custom field can cause data loss in the following situations. These are situations where you can incur data loss when you change from one type to another. I want you to take the time to work through these and think through these and see if you can understand why that might be. For example, just to pick one out, it’s when you change from a pick list multi select to any other type.
So if you were to go from a multi select pick list to a regular pick list, then any data records that have like three selections selected, you would lose at least two of those three selections, if not all three. If the new data type is a single picklist value option, and if the three that you’ve selected are not in this new list of singular options from a picklist field, then you would lose all the data. And so it’s saying that currently defined picklist values are retained when you change a picklist to a multi select pick list. And so this is kind of a note going the other way from picklist to multi select pick list. If records contain values that are not in the picklist definition, those values will be deleted from the records when the data type changes. So this is where we get into a common point of confusion when it deals with salesforce is that you’ve got data and then you’ve got metadata. So we’re looking at the metadata here.
This has to do with the different fields that are available and then we’re on the campaign object and then you’ve got individual campaign records that may have different selections for the type pick list, for example. So if you were to go in and change a field such as this picklist multi select pick list, we have a record for this where the social network was selected. So if we go to the campaign and I believe it was this one here, and it’s got a type of social and then the social networks are Facebook, Instagram and Snapchat. So if we go back to the field level in this object and change this field type for multiple select to just a single picklist, then you’ll see how we’re going to lose data.
So let me cancel out of this and cancel here and just bear in mind that we’ve got Facebook, Instagram and Snapchat on this particular record. So if I go in and view fields and then if you go to the custom fields and bear in mind you can only change the data type on custom fields. If I click on this and then click Edit, we’re going to go from multiple select picklist to a picklist. So to do that you click change field type and we’re going to go with picklist. Then it says changing to the selected data type will cause you to lose all existing data in this field. So I’m going to click okay and click next. And so we next have to enter the details. Below is a list of picklist values. Click Edit to change the name of the value or make it the default value. And so we have the four options carrying over from the multiple select, but now we can only select one.
We can specify a default, but I’m just going to leave everything the way that it is and click Save. And then we’re going to go back to our campaign and see the impact. Now that our social network field is now a picklist field, we have to refresh this to see the implications and see if we lose Facebook, Instagram and any other social network. So we have wiped out all the data in that record. Now what’s so dangerous about this? And this is a common mistake that new admins and developers make. And a reason why you always want to have good backups of all your data is because either you or someone else may inadvertently do some innocuous change and change this from a multi select pick list to just a regular pick list, and you have effectively wiped out all the data on all of your records for this object. Not a big deal if it’s one, but if it’s thousands, that can be catastrophic for your instance because you may have other automation in place or validation rules and you could literally bring thousands of people to a screaming halt if you do something like this. So it’s very important also when you’re changing field types that you do this first in a sandbox environment.
Now we’re just going wildly through these potentially large changes. It’s because we’re in a free developer account and not a production instance, but normally you would be testing these changes out in a safer environment and that would be a sandbox. And then you would test that to make sure there’s no data loss and that everything’s working accordingly. And then you would push this out to production through a change set, which we’ll show in a later lecture. So we’ve now demonstrated just how destructive these changes can be. And so now you can see I can only choose one of the multiple selections in a picklist. So I’m going to go ahead and save this record now that I’ve reverted this down to a picklist value. And so as I mentioned previously, there are so many considerations when changing custom field types.
The main things to bear in mind is that you can only do this on custom fields and there are some scenarios where you’ll lose data and some where you will not. And so the main thing is to think about this logically is that if you go from a long text field to a shorter text field, you’re going to have truncated data. And so I just encourage you to go through and look at all of these different scenarios. And here are additional restrictions even based on the different data types such as auto number here and formula fields, picklist fields, and then restrictions around relationship fields. So here’s a good one to highlight because we were just talking about master detail relationships and roll up summary fields and it says that after you have created a roll up summary field on an object, you cannot convert the object’s master detail relationship into a lookup relationship.
So there’s so many of these, and I spoke to this previously, the text area long is that when you convert a long text area field to an email phone text text area or URL type field, the data in your records is truncated to the first 255 characters of the field. So there’s literally dozens of scenarios here that are covered in this help page. And once again, this will be in the resources section of this lecture. So one of the things that you will want to revisit then, and we’ve covered enough this for now to just get you some exposure and some examples of how to think through these different scenarios logically. But as we progress through this course, we’ll run across other examples where changing field types may have an impact.
And as you get towards the end of this course, getting closer to thinking about scheduling your exam, you’ll want to definitely revisit this particular help page and know about data loss and its implications as it relates to field types. And this was definitely highlighted highly in the study guide as well. So I wanted to spend some considerable time around this. But we’re in the midst of the data modeling and management section and we’ve gone from the front end of creating individual fields to then relationships and other types of fields and roll up summary fields and now implicate applications of data loss. And so now as we delve deeper into the data modeling and management, it’s time to work in bulk and dealing with the data loader.
It’s a great tool that’s very useful for managing large amounts of data and importing and exporting data in and out of salesforce. So we’re going to first introduce and install the data loader in the next.
- Introducing and Installing the Data Loader
So as you progress towards becoming a developer on the salesforce platform, a tool that you’re going to need to become very familiar with is the data loader. So if you notice, I’ve searched for Data Loader in the Setup menu here in Lighting Experience and I’ve got a few options here and the one I want to highlight is the Data Loader option. Clicking on Data Loader and Setup just brings you to a page that provides the download links for Windows and Mac act.
So you can simply click on the download link to download the install file for the data loader. It’s important to note that this is a local install onto your own machine. And so you want to go through the process of installing the data loader. And so one thing you want to bear in mind or one thing that’s available to you is this help resource in developer documentation. Actually, these are considerations for installing the data loader that I wanted to highlight as far as some of the access that you need in order to use the data loader, install it.
So things on your user record that need to be checked, you need to have API enabled on your user record. And then as well as there’s some other notes here as well as far as the appropriate user permission for the operation you’re doing, you will need example create rights on accounts in order to insert new accounts. There’s also system requirements that some of my students have run into in my Admin course and that they’ve asked about. So these are the system requirements for Windows and some of the things to point out is it’s available for Windows seven, eight or ten. And then as well you need the Java runtime environment of 1. 832 bit at the time of this recording as well, they note that they no longer bundle Java with the data loader for Windows installer.
So you’ve got to download and install Java on your Windows computer and you do that first and then download and install Data Loader or you’ll see a prompt that you need to install Java first. The system requirements for the Mac OS are much the same as far as you need Java runtime environment 1. 8 and then as well the OS that this is compatible with is El Capitan right now. And so for the latest details around this, you can visit this page which I’ll make available in the Resources section of this lecture. And so once you’ve downloaded and installed the data loader, here’s what the data loader looks like once you’ve logged in.
And so I’m going to take you through the process of logging into the data loader in the next lecture. And also we’ll bring into play the token that you previously reset much earlier in this course. You may be called upon to use that token in order to log into the data loader. So we’ll next be logging into the Data loader.
- Logging in to the Data Loader with a Security Token
So now I’m going to show you how to log into the data loader and cover something that you may have to do, such as logging in using your security token. And this is a common point of confusion for a lot of new users. With the data loader. I want to double click the Data loader icon on my desktop to launch the data loader. And then I’m going to go ahead and expand this to fill up the full screen so that you’re not staring at my desktop the whole time. But when you first launched the data loader, if you tried to perform an action here, such as doing an insert, you’ll be prompted to log in.
And so you can either do OAuth authentication or password authentication by clicking the appropriate button. And so I’m going to go with OAuth and select Production for my environment and click Log In. And so that prompts me to enter in my password for my username. And once again, this is not my valid email address. I don’t know who owns it, so please don’t spam them. And so when entering my password now if you try to just enter your password and log in and if you receive an error message, then that means you need to attend your security token at the end of your password field. So what you would need to do is enter your password and then copy your token that you should have received when you went through an earlier lecture about resetting your security token in Salesforce.
And then just copy that and paste this on the end of your password field and then click Login. So what that would look like is you type in your password and click Log in. And then if it’s saying that you need to check your username or password, that’s when you would then append the token and try and log in that way. And so I don’t require security token to log into my own instance, so I’m just going to type my password. But I wanted to show you the different options you have as far as logging in either with or without the token. So I’ve entered my password.
I’m going to click Login after making sure that Remember Me is checked. And now that I’ve logged in successfully, it’s asking if I want to allow or deny the data loader access to my salesforce instance. I want to check Allow so it’s verifying the username and password, and then when it’s done, it says Login successful here. It’s a little confusing because the Login button still appears even though I’m successfully logged in. So now that we’ve successfully logged into the data loader in, the next lecture going to be getting into data loader configuration.
- Data Loader Configuration
So let’s discuss data loader configuration. Now I’m in the settings screen for my data loader. Let me cancel out that real quick and show you how to get there as you click on Settings from the menu in Data Loader and select Settings. It’s a redundant option, but it is what it is. So you can modify your settings here. So some of the things you can do is you can hide the welcome screen by checking this box. And then your batch size, it defaults the batch size of 200, you can actually increase that up to 2000 per batch and that uses the bulk API for salesforce. Another thing that you need to be careful with, with the data loader is this option to insert null values. I’ve inadvertently deleted data from Records by having this box checked and then by doing data uploads for mass upsets or updates of salesforce records. If you insert null values and if you have fields that have been blanked out in your spreadsheet and then you upload it, it’ll actually delete values.
So if you want to mass delete values on different rows of data, you could check inserting old values and purposefully delete those values and upset. But I want to avoid that for now. In general, it’s best practice to not insert old values unless you’re specifically going in to make some deletes of some values in some fields. Then the server host here, I have this to my own Salesforce instance, which is the NA 35 instance for my developer account. If I were going into a sandbox environment, you want to do test salesforce. com and that is the default login for sandbox environments. And then as well, you can just do login salesforce. com and that’s the default login for production instances. And so that’s one common point of confusion for newer developers is knowing where to log into if they’re going to a sandbox versus production. So just bearing in mind test salesforce. com for sandboxes and then login salesforce. com if you don’t know the specific server instance for a production environment.
But for mine I’ve got NA 35, so I’m going to stick with that. And so then some of these other settings around, like the timeout settings and the query request size, and then as well, you can generate status files for exports and then you can set encoding through some of these checkboxes here for read write. You can use European Date format by checking this box here, if that’s a requirement. You can also allow field truncation. If you uncheck this, then you’ll get a warning and the updates will fail because fields would truncate. But if you have thischecked it’ll automatically truncate. If you’re trying to import more data into a field, then it’ll hold. You can use the bulk API, like I mentioned earlier, if you’re wanting to do batch sizes of 2000, for instance.
And then some of these others just go well beyond the scope of the exam and some of these I’ve never used before, but as well you can specify your time zone that you’re in and that will help with the time date stamps accordingly. And then as well, you can also start a specific row, for instance, if you’ve got a common insert, for example, that you do. But I’m just going to cancel out of these settings for now. Once again, you can get to this from the settings menu in order to pull up and configure your data loader. And then as well, another common problem with this is that the window is usually too big for your screen and you’ve got to scroll down to see it all. So next we’re going to go more fully into the data loader and decide which tool is best for inserting or importing records.
But before we do that, I do want to discuss these different buttons here just to make it clear what they do. From left to right, we’ve got Insert, which is pretty obvious. We’re inserting new records, whereas Update, the second button here would update existing records in your salesforce instance. This third one you may not be familiar with, it’s not a commonly used term and that’s upset. Consider that a combination of these first two buttons and upset will insert new records and update existing records and it relies heavily on the salesforce ID to determine if a record already exists in your instance. Or it can also use other types of fields that we’ll get into later to be able to determine if these records that you’re uploading already exist or not.
So just bearing in mind up cert involves inserting and updating all at the same time. And then we have Delete, which has to do with deleting records from your salesforce instance, hard delete as well, which basically makes it not even available from your recycle bin. And then you can also perform export options for export or export all. So next we’re going to be dealing more fully with importing data and deciding which tool is best in salesforce, whether specifically we should use the Data Loader or the Data Import Wizard. And we give you some tools and some guidelines and criteria to help you make that decision. And also most importantly, to know what you might be asked on the exam as it relates to importing data and how to decide which tool to use. So stay tuned for the next lecture.