How to Create a Custom Field in Salesforce
Fields are how Salesforce keeps track of separate pieces of information.
For each Contact, for instance, there are different fields for name, address, title
and so on. But we know your business has unique needs so Lightning Experience makes it easy
to create custom fields so you can track any information you need to run your business
Let’s create a custom field on a Contact so we can track their preferred contact method.
We could use the cog to get to Setup and then the Object Manager, to locate the contact
object. But Lightning makes it even easier - we can
edit the object right here.
Edit Object is a shortcut to the Object Manager where you manage everything from record types
and page layouts to fields. Edit Page takes you into the lightning app
builder where you can arrange, and re-arrange the lightning components on a page.
Lets click Edit Object. Here in the Object Manager we’ll go the Fields and Relationships,
and click New We’ve got every type of field you could
want. From Number fields
To Formula fields A whole slew of text fields
You can even create fields that look up information already in Salesforce.
Lets grab picklist so users can pick the preferred method from a set list of choices.
Users love it when you save them the trouble of having to type by providing a list. And
it keeps data clean and makes your reports more accurate!
When you’re done selecting your field type click Next and Salesforce will lead you through
how to setup your field. Now we’ll enter the field details starting
with the label When naming your field, you will notice 2
fields called “Field Label” and “Field Name”. The Field Label is what you and your
users see throughout the user interface, while Field Name is used in the API.
The API name for custom fields will end in “__c”. Places you’ll see the API name
include the process builder, and when referencing fields within formulas.
Field Labels should be easy to understand, so we’ll name this “Preferred Contact
Method” We can use a global picklist, or one that’s
unique to this field. Global picklists are perfect for any list of values that you’ll
use one more than one field. Instead of recreating it for each field, you can create one of these
global lists, and then choose it here. To create a global picklist value set, enter
Picklist in the Quick Find box, then select Picklist Value Sets.
Next to Global Value Sets, click New.
However, this picklist is only applicable to this object, so we’ll enter the values
right here on this field, that we’re creating on the Contact object.
We’ll enter the values, with each value on its own line
Descriptions and help text are always a good idea!
The help text is displayed whenever a user mouses over the information icon next to the
field On to the next step.
Here we’ll establish field level security. For example, if we uncheck the visible box
next to the Marketing User profile, this field will be Invisible to any users assigned to
this profile. Even if this field is displayed on a page
layout, or added to a report, it will remain invisible to users with the General Marketing
User profile. The “Preferred Contact Method” field is
not considered sensitive data, so we can leave it visible to all profiles.
The last step is to choose which page layouts should display this field. Page layouts are
assigned by user profiles. We currently only use one layout for all our user profiles,
so we’ll add our new field to the layout. To finish creating this custom field, click
Save. Now this field will appear in the details
section of Abby’s contact record. You know what would be really helpful though?
To have this field displayed right at the top, here in the highlights panel!
Since the field has already been created, all we need to do is Edit the Page and add
that field to the highlights panel. Here in the app builder Click once on the
placeholder for the highlights panel. Now that its selected, the pane on the right displays
configuration settings related to that component. It tells us right here that the compact layout
controls which fields display here. This Lightning Record Page is using the Customer
Contact compact layout so we’ll click that And choose Edit.
We’ll add our new field and click save If we go back to Abby’s record and reload
the screen, ta-da! There’s our field, front and center so our salespeople don’t have
to scroll through the details tab to find it!
To learn more, check out these resources Or join us on the trail at trailblazer dot
salesforce dot com.