Customize Fields. salesforce Winter '18
Реклама
Реклама
Extend Salesforce with Clicks, Not Code Customize Fields
•
Custom settings are a type of custom object. Each custom setting counts against the total number of custom objects available for your organization.
•
Accessing an undeleted custom setting in a formula field results in an error if the user doesn’t have the “Customize Application” permission. To prevent this error, redeploy this custom setting to the organization. Alternatively, delete this custom setting, re-create it with the same name and data, and then delete and re-create all formula fields that use this setting.
•
If a cross-object formula references a currency field from a custom setting, this field value isn’t converted to the currency of the record containing the formula. The result of the formula could be inaccurate if the custom setting field’s currency and the record’s currency are different.
To see how much custom settings data your organization is using, from Setup, enter
Custom Settings
in the
Quick Find box, then select Custom Settings. For each custom setting, this page lists the size of one record, the number of records created, and the total size used for each custom setting.
Record size is based on the maximum field size of each field type, not the actual storage that’s used in each field. When adding fields to a custom setting definition, use the appropriate type and specify a length that doesn’t exceed what’s needed for your data. This action helps you avoid reaching the cached data limit. For example, if you create a US social security number (SSN) field, select the
Text
data type and specify a length of 9. If instead you selected a
Text Area
data type, the field would add 255 characters to the usage count for each record, regardless of the number of characters entered.
SEE ALSO:
Customize Fields
Customize standard and custom fields to tailor your org to your own unique requirements.
You can:
•
Modify some aspects of standard fields
•
Change or add values to standard and custom picklist fields
•
Define dependency rules between fields
•
Create custom fields to capture additional information
•
Create formula fields that automatically calculate values based on the contents of other fields
•
Define default values for custom fields
•
Define validation rules for your fields
•
Make a field required
•
Set fields to track changes, including the date, time, nature of the change, and who made the change
•
Create page layouts to control the display of fields
•
Set field-level security to control access to fields
•
Create or modify field sets
EDITIONS
Available in: both Salesforce
Classic and Lightning
Experience
Available in: All Editions
Standard Fields and Page
Layouts are not available in
Database.com
USER PERMISSIONS
To create or change custom fields:
•
Customize Application
You can customize several aspects of standard fields, such as the values in picklists, the format for auto-number fields, tracking field history, lookup filters on relationship fields, and field-level help.
Modify Standard Auto-Number Fields
127
Extend Salesforce with Clicks, Not Code Customize Fields
Capture your unique business data by storing it in custom fields. When you create a custom field, you configure where you want it to appear and optionally control security at the field level.
Define a default value for a field. Use a formula to generate dynamic values, or constants for static values.
Review examples of validation rules for various types of apps that you can use and modify for your own purposes. Validation rules verify that the data a user enters in a record meets the standards you specify before the user can save the record.
Require Field Input to Ensure Data Quality
Improve the quality of data that users enter in Salesforce by creating universally required fields.
A roll-up summary field calculates values from related records, such as those in a related list. 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. The detail record must be related to the master through a master-detail relationship. For example, you want to display the sum of invoice amounts for all related invoice custom object records in an account’s Invoices related list. You can display this total in a custom account field called Total Invoice Amount.
Improve user productivity and data quality with lookup filters. Lookup filters are administrator settings that restrict the valid values and lookup dialog results for lookup, master-detail, and hierarchical relationship fields.
Customize Standard Fields
You can customize several aspects of standard fields, such as the values in picklists, the format for auto-number fields, tracking field history, lookup filters on relationship fields, and field-level help.
Tip: You can’t delete standard fields, but you can remove them from your page layouts.
1. Navigate to the fields page for your object.
2. Click the field label.
3. To add custom help text, click Edit.
4. On the field’s information page, you can—depending on your Edition—set field-level security, view accessibility settings, and configure validation rules.
You can also do more, depending on the field’s type. For example, if the field is a picklist, you can add, delete, and reorder its values, and set dependencies. You can’t increase the field length of a standard field. If you need a longer text area, consider creating a custom field.
EDITIONS
Available in: both Salesforce
Classic and Lightning
Experience
Available in: All Editions except for Database.com.
USER PERMISSIONS
To change standard fields:
•
Customize Application
Beyond the Basics
What does that
Indexed
checkbox mean on a field, and how did it get there?
128
Extend Salesforce with Clicks, Not Code Customize Fields
If a field is indexed, you can use sidebar search or advanced search to find values in the field. Having a field indexed can also speed up other operations on the field, such as reporting. Check out this blog post to find out more: Know Thy Salesforce Field
Indexes for Fast Reports, List Views, and SOQL .
SEE ALSO:
Rename Object, Tab, and Field Labels
Getting Started with Field-Level Help
Modify Standard Auto-Number Fields
The unique identifiers for solutions, cases, and contracts are standard auto-number fields. Each record is assigned a unique number with a specified format upon creation. You can modify the format and numbering for these auto-number fields.
1. From the management settings for the object whose field you want to modify, go to the fields area.
2. Click Edit next to the name of the field.
3. Enter a
Display Format
to control such formatting details as the minimum number of leading zeros as well as any prefix or suffix for the number. See
Custom Field Attributes on page
142.
Format changes do not affect existing records; they are applied only to new records.
4. Enter the number to be assigned to the next record that is created after you save your changes.
5. Click Save.
Warning:
Salesforce warns you if the next number you enter is not higher than existing numbers. However, it may be possible to create duplicate numbers if you change the auto-number format multiple times using similar formats each time.
SEE ALSO:
EDITIONS
Available in: both Salesforce
Classic and Lightning
Experience
Available in: Contact
Manager, Group,
Professional, Enterprise,
Performance, Unlimited, and Developer Editions
USER PERMISSIONS
To modify standard auto-number fields:
•
Customize Application
129
Extend Salesforce with Clicks, Not Code Customize Fields
Custom Fields
To tailor your organization, you can add custom fields for each of the tabs and objects that your organization uses.
For the total number of custom fields you can create, see Salesforce Limits.
Note: When your org is close to the limit of 800 custom fields and you delete or create fields, field creation can fail. The physical delete process reclaims and cleans fields, making them count temporarily toward the limit. The delete process runs only when the queue is full, so it can take days or weeks to start. In the meantime, the deleted fields are still counted as part of the limit. To request immediate deletion of fields, contact Salesforce Support.
See the following for more information:
•
•
•
Manage Fields for a Specific Object
•
•
•
Create a Custom Picklist Field
•
•
•
Additional Custom Field Options
•
•
EDITIONS
Available in: both Salesforce
Classic and Lightning
Experience
Available in: All Editions
Tabs are not available in
Database.com
USER PERMISSIONS
To create or change custom fields:
•
Customize Application
130
Extend Salesforce with Clicks, Not Code Customize Fields
Create Custom Fields
Capture your unique business data by storing it in custom fields. When you create a custom field, you configure where you want it to appear and optionally control security at the field level.
Watch a Demo: How to Create a Custom Field in Salesforce
Want to customize Salesforce so it captures all your business data? This short video walks you through how to create a custom picklist field, from choosing the correct field type to applying field level security.
Before you begin, determine the type of field you want to create.
EDITIONS
Available in: both Salesforce
Classic and Lightning
Experience
Note:
When your org is close to the limit of 800 custom fields and you delete or create fields, field creation can fail. The physical delete process reclaims and cleans fields, making them count temporarily toward the limit. The delete process runs only when the queue is full, so it can take days or weeks to start. In the meantime, the deleted fields are still counted as part of the limit. To request immediate deletion of fields, contact Salesforce Support.
1. From the management settings for the object you want to add a field to, go to Fields.
Custom task and event fields are accessible from the object management settings for Activities.
2. Click New.
Available in: Contact
Manager, Group,
Professional, Enterprise,
Performance, Unlimited,
Developer, and
Database.com Editions
Salesforce Connect external objects are available in:
Developer Edition and for an extra cost in: Enterprise,
Performance, and
Unlimited Editions
Custom fields aren’t available on Activities in
Group Edition
Tip: On custom objects, you can also set
field dependencies and field history tracking in
this section.
3. Choose the type of field and click Next. Consider the following.
•
Some data types are available for certain configurations only. For example, the
Master-Detail Relationship
option is available for custom objects only when the custom object doesn’t already have a master-detail relationship.
•
Custom settings and external objects allow only a subset of the available data types.
•
You can’t add a multi-select picklist, rich text area, or dependent picklist custom field to opportunity splits.
•
Relationship fields count towards custom field limits.
•
Additional field types may appear if an AppExchange package using those field types is installed.
•
The
option is available on certain objects only.
Custom settings aren’t available in Professional
Edition
Layouts aren’t available in
Database.com
USER PERMISSIONS
To create or change custom fields:
•
Customize Application
•
Field types correspond to API data types.
•
If your organization uses Shield Platform Encryption, ensure you understand how to encrypt custom fields using the Shield
Platform Encryption offering.
4. For relationship fields, associate an object with the field and click Next.
5. For indirect lookup relationship fields, select a unique, external ID field on the parent object, and then click Next. The parent field values are matched against the values of the child indirect lookup relationship field to determine which records are related to each other.
6. To base a picklist field on a global picklist value set, select the value set to use.
7. Enter a field label.
Salesforce populates
Field Name
using the field label. This name can contain only underscores and alphanumeric characters, and must be unique in your org. It must begin with a letter, not include spaces, not end with an underscore, and not contain two
131
Extend Salesforce with Clicks, Not Code Customize Fields consecutive underscores. Use the field name for merge fields in custom links, custom s-controls, and when referencing the field from the API.
Tip: Ensure that the custom field name and label are unique for that object.
•
If a standard and custom field have identical names or labels, the merge field displays the custom field value.
•
If two custom fields have identical names or labels, the merge field may display an unexpected value.
If you create a field label called
and a standard field labeled
already exists, the merge field may be unable to distinguish between the fields. Adding a character to the custom field name makes it unique. For example,
Email2
.
8. Enter
and select the appropriate checkboxes to specify whether the field must be populated and what happens if the record is deleted.
9. For master-detail relationships on custom objects, optionally select Allow reparenting to allow a child record in the master-detail relationship to be reparented to a different parent record.
10. For relationship fields, optionally create a lookup filter to limit search results for the field. Not available for external objects.
11. Click Next.
12. In Enterprise, Unlimited, Performance, and Developer Editions, specify the field’s access settings for each profile, and click Next.
Access Level
Users can read and edit the field.
Users can read but not edit the field.
Users can’t read or edit the field.
Enabled Settings
Visible
Visible and Read-Only
None
Note:
•
When you create a custom field, by default the field isn’t visible or editable for portal profiles, unless the field is
.
13. Choose the page layouts that will display the editable field and click Next.
Field
Normal
Long text area
User
Universally required
Location on Page Layout
Last field in the first two-column section.
End of the first one-column section.
Bottom of the user detail page.
Can’t remove it from page layouts or make read only.
14. For relationship fields, optionally create an associated records related list and add it to page layouts for that object.
•
To edit the related list name on page layouts, click Related List Label and enter the new name.
•
To add the related list to customized page layouts, select
Append related list to users’ existing personal customizations
.
15. Click Save to finish or Save & New to create more custom fields.
132
Extend Salesforce with Clicks, Not Code Customize Fields
Note: Creating fields may require changing a large number of records at once. To process these changes efficiently, your request may be queued and you may receive an email notification when the process has completed.
Create a Custom Picklist Field
Create custom picklist fields to let your users select values from lists that you define.
Create a Global Picklist Value Set
Use global picklist value sets to share values across objects and custom picklist fields, and to restrict the picklists to only the values that you specify.
Make Your Custom Picklist Field Values Global
When you create a custom picklist, it’s only available to the current object. To share the values with other objects, promote the picklist to a global value set. The original custom picklist references the global value set for its values, and the global value set is also available to other custom picklists.
What’s the Difference between Standard Fields and Custom Fields?
You can add custom fields to standard and custom objects in Salesforce, allowing you to infinitely customize your organization.
Although custom fields are similar to the standard fields that come built-in to Salesforce, there are some differences between standard fields and custom fields.
A custom field entry consists of several attributes.
The geolocation custom field allows you to identify locations by their latitude and longitude and to calculate distances between locations.
Manage Fields for a Specific Object
Deleted custom fields and their data are stored until your org permanently deletes them or 15 days has elapsed, whichever happens first. Until that time, you can restore the field and its data.
Additional Custom Field Options
Editing Rich Text Area Fields in Records
Use rich area text fields to improve the appearance of text, including adding images and hyperlinks.
Rich Text Area Field Limitations
Keep these limitations in mind when working with rich text area fields.
Classic Encryption for Custom Fields
Restrict other Salesforce users from seeing custom text fields you want to keep private. Only users with the permission “View Encrypted
Data” can see data in encrypted custom text fields.
Track time, unbound to a date, with this custom field type. The time type is useful for time management, event planning, and project management.
Add or edit values in a custom picklist from the fields area of an object. If the picklist uses a global picklist value set, you can change its values only by editing the global value set. Your changes affect all picklists that inherit their values from that global value set.
133
Extend Salesforce with Clicks, Not Code
Use the rich text editor to format text in custom fields with the rich text area type and in many other features, such as Chatter publisher and groups.
SEE ALSO:
Find Object Management Settings
Create a Custom Picklist Field
Create custom picklist fields to let your users select values from lists that you define.
EDITIONS
Watch a Demo: Custom Fields: Picklists
You can create these types of picklist fields:
•
Local picklist—Lets users select a single value from a list that you define. This picklist is unique and had its own set of values.
•
Shared picklist—Lets users select a single value from a global picklist value set that you define in Setup. All custom picklist fields that use a global value set inherit its values and can’t have additional values.
•
Multi-select picklist—Allows users to select more than one picklist value from a list that you define. These fields display each value separated by a semicolon.
Available in: Salesforce
Classic and Lightning
Experience
Available in all editions
USER PERMISSIONS
To create or change custom fields:
•
Customize Application
Note: You can’t add a multi-select picklist, rich text area, or dependent picklist custom field to opportunity splits.
1. Go to the fields area of the object you want to create a picklist field for.
2. In the custom fields related list, click New.
3. Select Picklist or Picklist (Multi-Select), and then click Next.
4. Enter a label for the picklist field.
5. To use the values from an existing global picklist, select Use global picklist value set. To use values that you create specifically for this picklist, select Enter values for the picklist, with each value separated by a new line.
Tip:
Provide feedback and suggestions for global picklists in the Global, Restricted Custom Picklists group in the Salesforce
Success Community .
6. If you didn’t use a global picklist value set, enter picklist values.
Put each value on a separate line. Values can be up to 255 characters long.
7. Optionally, sort the values alphabetically or use the first value in the list as the default value, or both.
If you select both options, Salesforce alphabetizes the entries and then sets the first alphabetized value as the default.
Note:
You can use a formula to assign a default value dynamically. For example, you can assign a value based on the current user. The following formula sets an Opportunity priority to High for all users in the Fast Response Sales profile. Other users see the default listed in the Values set.
134
Customize Fields
Extend Salesforce with Clicks, Not Code Customize Fields
IF($Profile.Name = "Fast Response Sales", "High", "")
For picklists, a valid formula result is either a constant or the API name of an entry in the Values list. The formula result has higher precedence than the default assigned in the Values list. If the formula doesn’t generate a valid result, the default assigned in the
Values list is entered in the field. If a default is not assigned to the Values list, no value is entered in the picklist field.
8. Choose whether to restrict this picklist’s values to an admin-approved list. Selecting Restrict picklist to the values defined in the
value set prevents users from loading unapproved values through the API.
9. If you’re creating a multi-select picklist, enter how many values you want displayed at a time on edit pages. The number of values determines the box height.
10. Enter description or help text if desired, and then click Next.
11. Set field-level security for the picklist field, and then click Next.
12. Choose the page layouts on which to include the picklist field.
13. Click Save.
SEE ALSO:
Create a Global Picklist Value Set
Make Your Custom Picklist Field Values Global
Create a Global Picklist Value Set
Use global picklist value sets to share values across objects and custom picklist fields, and to restrict the picklists to only the values that you specify.
EDITIONS
Note: Give your feedback and suggestions for global picklists in the Global, Restricted Custom
Picklists group in the Salesforce Success Community .
A custom picklist is tied to a particular object as a field on the object. Unlike a custom picklist field, a global picklist exists independently as a global picklist value set. Its values are shared with any picklist that’s based on it.
A global picklist is a restricted picklist by nature. Only a Salesforce admin can add to or modify its values. Users can’t add unapproved values, even through the API.
Available in: Salesforce
Classic and Lightning
Experience
Available in: All Editions
USER PERMISSIONS
Note:
You can have up to 500 picklist global value sets in an org. Each global value set, or restricted picklist, can contain a mix of 1,000 active and inactive values. Unrestricted picklists can have up to 1,000 active values. There’s no limit on the number of custom picklists that use global picklist value sets.
1. From Setup, enter
Picklist
in the
Quick Find
box, then select Picklist Value Sets.
To create or change custom fields:
•
Customize Application
2. Next to Global Value Sets, click New.
3. Enter a label for the global value set. This name appears in Setup, and when users create a picklist based on this global value set.
4. To tell users what these values are for, enter a specific description of the global value set. This text appears on the Picklist Value Sets list page in Setup.
5. Enter the values, one per line.
135
Extend Salesforce with Clicks, Not Code Customize Fields
6. Optionally choose to sort the values alphabetically or to use the first value in the list as the default value, or both. You can’t change these settings later.
If you select both options, Salesforce alphabetizes the entries and then sets the first alphabetized value as the default.
7. Click Save.
Your global value set is ready to be used in custom picklist fields. You can reorder the values by clicking Reorder.
To create a picklist that uses a global picklist value set, see Create a Custom Picklist Field
.
To see all the fields where this value set is used, look under Fields Where Used on the global picklist’s detail page.
As you add new values to an existing global picklist, you can add the new values to all record types that use the picklist. Select Add the
new picklist values to all Record Types that use this Global Value Set; otherwise, you have to add the new values to existing records types manually.
SEE ALSO:
Manage Inactive Picklist Values
Create a Custom Picklist Field
Make Your Custom Picklist Field Values Global
Make Your Custom Picklist Field Values Global
When you create a custom picklist, it’s only available to the current object. To share the values with other objects, promote the picklist to a global value set. The original custom picklist references the global value set for its values, and the global value set is also available to other custom picklists.
Note: After a picklist is promoted to a global value set, you can’t demote it. You manage the values in the global value set or edit the custom picklist field to use different values.
1. Go to the fields area of the object you want to create a picklist field for.
2. In the Custom Fields related list, click Edit.
3. Click Promote to Global Value Set.
EDITIONS
Available in: Salesforce
Classic and Lightning
Experience
Available in all editions
USER PERMISSIONS
To create or change custom fields:
•
Customize Application
4. Enter a label for the global value set.
136
Extend Salesforce with Clicks, Not Code Customize Fields
5. Accept the Field Name or edit it.
6. Optionally, enter a description to identify it when using the values for other custom picklists.
7. Click Promote to Global Value Set, again.
You can use the new global value set for other fields and manage the values in Picklist Value Sets.
When promoting a custom picklist, be aware of the following.
•
You can promote fields that have up to 1,000 values (both active and inactive).
•
You can promote only restricted picklists. To promote an unrestricted picklist, convert it to a restricted picklist.
•
You cannot promote a field to an existing global value set.
•
For an app to help manage picklist values, see Picklist Field Merge Salesforce Lab App .
SEE ALSO:
Create a Custom Picklist Field
Create a Global Picklist Value Set
Custom Field Types
When you have data that doesn’t match any of the standard fields, your administrator can create a custom field for that data. For example, you might want a
Middle Name
field for contacts.
The first step in creating a custom field is choosing the type of the field. Below is a description of each custom field type. Additional field types may appear if an AppExchange package using those field types is installed.
Type
Auto Number
Checkbox
Currency
Description
Automatically assigns a unique number to each record. The maximum length of any auto-number field is 30 characters, 20 of which are reserved for prefix or suffix text. Not available for external objects.
Allows users to check a box, indicating a true or false attribute of a record. When using a checkbox field for a report or list view filter, use “True” for checked values and “False” for unchecked values.
The Data Import Wizard and the weekly export tool use “1” for checked values and “0” for unchecked values.
Allows users to enter a currency amount. The system automatically formats the field as a currency amount. This can be useful if you export data to a spreadsheet application. Not available for external objects.
Note: Salesforce uses the round-half-to-even tie-breaking rule for currency fields. For example, 23.5 becomes 24, 22.5
becomes 22, −22.5 becomes −22, and −23.5 becomes −24.
Values lose precision after 15 decimal places.
Date
Allows users to enter a date or pick a date from a popup calendar.
In reports, you can limit the data by specific dates using any custom date field.
137
Extend Salesforce with Clicks, Not Code
Type
Date/Time
External Lookup Relationship
Formula
Geolocation
Hierarchical Relationship
Indirect Lookup Relationship
138
Customize Fields
Description
Allows users to enter a date or pick a date from a popup calendar and enter a time of day. They can also add the current date and time by clicking the date and time link next to the field. The time of day includes AM or PM notation. In reports, you can limit the data by specific dates and times using any custom date field.
Allows users to enter an email address of up to 80 characters, which is validated to ensure proper format. If this field is specified for contacts or leads, users can choose the address when clicking Send
an Email. Note that you can't use custom email addresses for mass emails.
Note: This field can be encrypted using Shield Platform
Encryption.
An external lookup relationship links a child standard, custom, or external object to a parent external object. When you create an external lookup relationship field, the standard External ID field on the parent external object is matched against the values of the child’s external lookup relationship field. External object field values come from an external data source.
Allows users to automatically calculate values based on other values or fields such as merge fields. Not available for external objects.
Note: Salesforce uses the round half up tie-breaking rule for numbers in formula fields. For example, 12.345 becomes
12.35 and −12.345 becomes −12.34.
Allows users to specify a location by its latitude and longitude.
Geolocation is a compound field that counts toward your org’s limits as three custom fields: one for latitude, one for longitude, and one for internal use. Not available for external objects.
Creates a hierarchical lookup relationship between users. Allows users to use a lookup field to associate one user with another that does not directly or indirectly refer to itself. For example, you can create a custom hierarchical relationship field to store each user's direct manager.
An indirect lookup relationship links a child external object to a parent standard or custom object. When you create an indirect lookup relationship field on an external object, you specify the parent object field and the child object field to match and associate records in the relationship. Specifically, you select a custom unique, external ID field on the parent object to match against the child’s indirect lookup relationship field, whose values come from an external data source.
Extend Salesforce with Clicks, Not Code
Type
Lookup Relationship
Master-Detail Relationship
Number
139
Customize Fields
Description
Creates a relationship between two records so you can associate them with each other. For example, opportunities have a lookup relationship with cases that lets you associate a particular case with an opportunity.
•
On a standard or custom object, a lookup relationship creates a field that allows users to click a lookup icon and select another record from a popup window.
•
On an external object, the lookup relationship field references
18-character Salesforce IDs that are stored in an external data source. Those IDs are matched against the parent object to determine which records are related to each other.
On the parent record, you can display a related list to show all of the records that are linked to it. You can create lookup relationship fields that link to users, standard objects, or custom objects. If a lookup field references a record that has been deleted, Salesforce clears the value of the lookup field by default. Alternatively, you can choose to prevent records from being deleted if they’re in a lookup relationship.
Lookup relationship fields are not available in Personal Edition.
Lookup relationship fields to campaign members are not available; however, lookup relationship fields from campaign members to standard or custom objects are available.
Creates a relationship between records where the master record controls certain behaviors of the detail record such as record deletion and security.
Not available for standard objects or external objects, although you can create a master-detail relationship field on a custom object that links to a standard object.
Master-detail relationships cannot be used with campaign members.
Allows users to enter any number. This is treated as a real number and any leading zeros are removed.
Note: Salesforce uses the round half up tie-breaking rule for number fields. For example, 12.345 becomes 12.35 and
−12.345 becomes −12.34. Salesforce rounds numbers referenced in merge fields according to the user’s locale, not the number of decimal spaces specified in the number field configuration.
Extend Salesforce with Clicks, Not Code
Type
Percent
Phone
Picklist
Picklist (Multi-select)
Roll-Up Summary
Text
Text (Encrypted)
140
Customize Fields
Description
Allows users to enter a percentage number as a decimal—for example,
0.10
. The system automatically converts the decimal to a percentage—for example,
10%
.
Note: Values lose precision after 15 decimal places. Also, if you enter a value with more than 15 decimal places and add a percent sign to the number, a runtime error occurs.
Allows users to enter any phone number. Character limit is 40.
Salesforce automatically formats it as a phone number.
If you are using Salesforce CRM Call Center, custom phone fields are displayed with the button, allowing click-to-dial functionality. Consequently, Salesforce recommends that you do not use a custom phone field for fax numbers.
Note: This field can be encrypted using Shield Platform
Encryption.
Lets users select a single value from a list that you define. Available for external objects only with the cross-org adapter for Salesforce
Connect.
Allows users to select more than one picklist value from a list that you define. These fields display each value separated by a semicolon. Available for external objects only with the cross-org adapter for Salesforce Connect.
Automatically displays the record count of related records or calculates the sum, minimum, or maximum value of related records.
The records must be directly related to the selected record and on the detail side of a custom master-detail relationship with the object that contains the roll-up summary field. For example, a custom field called “Total Number of Guests” displays the number of guest custom object records in the Guests related list. Not available for external objects.
Allows users to enter any combination of letters, numbers, or symbols. You can set a maximum length, up to 255 characters.
Note: This field can be encrypted using Shield Platform
Encryption.
Allows users to enter any combination of letters, numbers, or symbols that are stored in encrypted form. You can set a maximum length of up to 175 characters. Encrypted fields are encrypted with
128-bit master keys and use the Advanced Encryption Standard
(AES) algorithm. You can archive, delete, and import your master encryption key. To enable master encryption key management, contact Salesforce. Not available for external objects.
Extend Salesforce with Clicks, Not Code
Type
Text Area
Text Area (Long)
Text Area (Rich)
URL
SEE ALSO:
Customize Fields
Description
Note: This field can be encrypted using Classic Encryption.
If your org uses Shield Platform Encryption, use
Text
to create an encrypted text field.
Allows users to enter up to 255 characters that display on separate lines similar to a
Description
field.
Allows users to enter up to 131,072 characters that display on separate lines similar to a
Description
field. You can set the length of this field type to a lower limit, if desired. Any length from
256 to 131,072 characters is allowed. The default is 32,768 characters. Note that every time you press
Enter
within a long text area field, a line break and a return character are added to the text. These two characters count toward the 131,072 character limit. This data type is not available for activities or products on opportunities. Only the first 254 characters in a rich text area or a long text area are displayed in a report.
Note: This field can be encrypted using Shield Platform
Encryption.
With the use of a toolbar, users can format the field content and add images and hyperlinks. The toolbar allows the user to undo, redo, bold, italicize, underline, strike-out, add a hyperlink, upload or link to an image, modify alignment, add a numbered or non-numbered list, indent, and outdent. The maximum field size is 131,072 characters, inclusive of all the formatting and HTML tags.
Only the first 254 characters in a rich text area or a long text area are displayed in a report. The maximum size for uploaded images is 1MB. Only gif
, jpeg
and png
file types are supported. Not available for external objects. There are visual and formatting differences for rich text areas in Lightning Experience and
Salesforce1, compared to Salesforce Classic.
Allows users to enter up to 255 characters of any valid website address. When users click on the field, the URL will open in a separate browser window. Note that only the first 50 characters are displayed on the record detail pages.
Note:
This field can be encrypted using Shield Platform
Encryption.
141
Extend Salesforce with Clicks, Not Code Customize Fields
What’s the Difference between Standard Fields and Custom Fields?
You can add custom fields to standard and custom objects in Salesforce, allowing you to infinitely customize your organization. Although custom fields are similar to the standard fields that come built-in to Salesforce, there are some differences between standard fields and custom fields.
EDITIONS
Custom objects and fields let you tailor which data is stored to fit your organization’s needs. Though the Force.com database provides several standard objects and accompanying standard fields, you can easily customize how you track and report on your data.
Available in: both Salesforce
Classic and Lightning
Experience
Available in all editions
Custom objects give you the flexibility to store any type of enterprise data that’s relevant to your app, by creating objects. For example, if you’re building a recruiting app, you can create custom objects called Position and Candidate to track information on job openings and candidates, respectively.
Categorize and track your data even more granularly by using custom fields. Like standard objects, custom objects have fields that define the data for those object records. You can, for example, add a custom number field
Years of Experience
to the custom candidate object or a custom text field
Description
to the custom position object. You can add custom fields to both custom and standard objects.
See the following for more information:
•
•
•
Manage Fields for a Specific Object
•
•
•
Additional Custom Field Options
•
•
Custom Field Attributes
A custom field entry consists of several attributes.
Field
# Visible Lines
Calculation Options
Child Relationship Name
Data Type
Description
For long text area fields, set the number of lines to be displayed on edit pages.
You can display between 2 and 50 lines (the default is 6 lines). If the text does not fit in the specified number of visible lines, scroll bars appear. Long text area fields are fully displayed on detail pages and printable views.
Determines how a
is recalculated after its properties change.
Choose
Automatic calculation
to recalculate a field the next time it’s displayed. Choose
Force a mass recalculation of this field as a safety net option to force recalculation of the roll-up summary field values.
The name used in API SOQL relationship queries.
The data type of a field determines what type of information is in the field. For example, a field with the Number data type contains a positive or negative integer.
For more information on data types, see Custom Field Types
on page 137.
142
Extend Salesforce with Clicks, Not Code
Field
Decimal Places
Default Value
Description
Display Format
Encrypted
External Column Name
External ID
Customize Fields
Description
For currency, geolocation, number, and percent fields, this field represents the number of digits you can enter to the right of a decimal point. The system rounds the decimal numbers you enter, if necessary. For example, if you enter
4.986
in a field with
Decimal Places
set to
2
, the number rounds to 4.99.
The value to apply when a user creates a record. For checkbox custom fields, choose Checked or Unchecked as the default value to indicate the default when creating records. Don’t assign default values to fields that are both required and unique, because uniqueness errors can result. See
on page
184.
Text that describes the custom field. This description is for administration purposes only and doesn’t display to users on record detail and edit pages that include the field.
For auto-number fields, enter a
Display Format
to control formatting details such as the minimum number of leading zeros and any prefix or suffix for the number.
Begin by entering the required minimum {0} as a placeholder for the auto-number without any leading zeros. Add any prefix to your number before this placeholder and insert any suffix text after the placeholder. Insert any date prefixes or suffixes in the form of {YY}, {YYYY}, {MM}, or {DD}, which represent the record creation date in Greenwich Mean Time (GMT).
For information on using auto-number formats when entering your
Display
Format
, see
Auto-Number Formatting Examples on page 147.
If checked, this custom field is encrypted using Shield Platform Encryption.
Note: This page is about Shield Platform Encryption, not Classic
Encryption. What's the difference?
Available on external objects only. Maps the custom field to an external data source’s table column.
For a lookup relationship field, specify the external table column that contains
18-character Salesforce IDs.
For each object that can have custom fields, you can set up to seven custom auto-number, email, number, or text fields as external IDs. An external ID field contains record identifiers from a system outside of Salesforce.
You can use an external ID field to update or upsert records using the API. When using the API or the Data Import Wizard for custom objects and solutions, you can use this field to prevent duplicates by also marking the field as
Note:
Custom fields marked as
count against an object's limit of seven
External ID
fields. Custom indexing that occurs automatically in the background by Salesforce does not count against
External ID limits.
143
Extend Salesforce with Clicks, Not Code Customize Fields
Field
Filter Criteria
Filtering Disabled
Formulas
Help Text
Is Name Field
Label
Latitude and Longitude Display Notation
Description
Not available for external objects. Each external object has an
External ID standard field. Its values uniquely identify each external object record in your org.
The criteria used to select a group of records to calculate the value of a
.
For custom fields on external objects, determines whether the field is available in filters.
Enter the formula for the custom formula field or custom summary formula for reports.
The text that displays in the field-level help hover text for this field.
For external object fields of type text, specifies this custom field as the name field for the external object. Not available for text area fields. By default, the External
ID standard field is the name field for the external object.
If you select this checkbox, make sure that the External Column Name specifies a table column that contains name values. Each external object can have only one name field.
For internal use only, Salesforce stores the value of the name field from each row that’s retrieved from the external system. This behavior doesn’t apply to external objects that are associated with high-data-volume external data sources.
The name of the custom field as you want it to appear.
For geolocation fields, determines how the latitude and longitude notation appears in the Salesforce interface.
Degrees, Minutes, Seconds
A notation for angular measurement that is based on the number 60: there are 360 degrees to a circle, 60 minutes to a degree, and 60 seconds to a minute.
Decimal
Expresses the value as degrees, and converts the minutes and seconds to a decimal fraction of the degree. Decimal notation doesn’t use cardinal points.
North and East are positive values; South and West are negative values.
For example, the coordinates for San Francisco can be expressed as follows:
Degrees,
Minutes,
Seconds
Decimals
Latitude
37° 46' 30" N
37.794016°
Longitude
122° 25' 5" W
–122.395016°
Regardless of the notation you choose to display in the interface, latitude and longitude are stored in Salesforce as decimals.
144
Extend Salesforce with Clicks, Not Code Customize Fields
Field
Length (for text fields)
Length (for number, currency, percent fields)
Mask Character
Mask Type
Master Object
Related List Label
Related To
Required
Description
For text fields, the maximum number of characters that a user can enter in a field
(up to 255 characters).
For number, currency, and percent fields, the number of digits you can enter to the left of the decimal point, for example, 123.98 for an entry of 3.
For encrypted text fields, determines the character to use for hidden characters.
Available options are * and X.
For text fields encrypted with Classic Encryption, determines which characters are hidden and the use of dashes in the field. Masked characters are hidden using the character selected in
Mask Character
. Available options are:
Mask All Characters
All characters in the field are hidden.
Last Four Characters Clear
All characters are hidden but the last four display.
Credit Card Number
The first 12 characters are hidden and the last four display. Salesforce automatically inserts a dash after every fourth character.
National Insurance Number
All characters are hidden. Salesforce automatically inserts spaces after each pair of characters if the field contains nine characters. Use this option for UK
NINO fields.
Social Security Number
The first five characters are hidden and the last four display. Salesforce automatically inserts a dash after the third and fifth characters.
Social Insurance Number
All characters are hidden but the last three display. Salesforce automatically inserts a dash after the third and sixth characters.
The object on the master side of a master-detail relationship used to display the value of a
For relationship fields, the title for the related list that displays associated records on the parent record.
For relationship fields, the name of the associated object.
Makes the field required everywhere in Salesforce. Not available for external objects.
You must specify a
for required campaign member custom fields.
Don’t assign default values to fields that are both required and unique, because
uniqueness errors can result. See Require Field Input to Ensure Data Quality
on page 228.
145
Extend Salesforce with Clicks, Not Code
Field
Roll-Up Type
Starting Number
Customize Fields
Description
, choose the type of calculation to make:
Type
COUNT
SUM
MIN
MAX
Description
Totals the number of related records.
Totals the values in the field you select in the
Field to
Aggregate
option. Only number, currency, and percent fields are available.
Displays the lowest value of the field you select in the
Field to
Aggregate
option for all directly related records. Only number, currency, percent, date, and date/time fields are available.
Displays the highest value of the field you select in the
Field to Aggregate
option for all directly related records. Only number, currency, percent, date, and date/time fields are available.
For auto-number fields, enter a
Starting Number
that’s less than 1 billion.
Select
Generate Auto Number for existing records
to automatically number all current records that begin with the starting number that you enter. If deselected, the next record that you enter is assigned the starting number and your older records are blank in this field. For leads, only unconverted leads are assigned a number.
When you create records,
Starting Number
’s value increments to store the number that will be assigned to the next auto-number field created. You can’t edit
Starting Number
after creating an auto-number field. To edit a
Starting Number
value, change your auto-number field to a text field and then back to an auto-number field. To restart
Starting Number
values for fields on objects from a managed package, uninstall and then reinstall the package.
Warning:
Be sure that you don’t create records with duplicate auto-number values.
An auto-number field can contain up to 10 digits and up to 20 extra characters for your prefix or suffix.
Note:
•
You can’t retrieve the starting number of an auto-number field through
Metadata API. To specify a
Starting Number
while deploying, add a startingNumber
tag for your field to your package.xml
file. For example:
<startingNumber>42</startingNumber>
•
If you deploy without specifying a
Starting Number
value in your package.xml
file, the default starting number for standard fields is
0
. The default starting number for custom fields is
1
.
146
Extend Salesforce with Clicks, Not Code Customize Fields
Field
Sharing Setting
Sorting Disabled
Summarized Object
Unique
Values
Description
For master-detail relationship fields, the
Sharing Setting
attribute determines the sharing access that users must have to a master record to create, edit, or delete its associated detail records.
For custom fields on external objects, determines whether the field is sortable.
The object on the detail side of a master-detail relationship used to provide the
values calculated in a roll-up summary field
.
If checked, prevents duplicate field values.
For text fields, you can control whether values that are identical except for their case are considered unique. Select
Treat "ABC" and "abc" as duplicate values
to enforce case-insensitive uniqueness, or select
Treat
"ABC" and "abc" as different values
to enforce case-sensitive uniqueness.
Note: Some characters have both single-byte and double-byte versions.
For example, all the following characters have single-byte and double-byte versions: “!@#$%^&*(){}[]\|:";',.<>?/~`”.
For the purpose of unique field value comparison, the single-byte and double-byte versions of these characters are considered identical.
Superscript characters are not treated as unique characters. Text such as
ABC² and ABC2 are considered identical.
Note: Custom fields marked as
count against an object's limit of seven
External ID
fields. Custom indexing that occurs automatically in the background by Salesforce does not count against
External ID limits.
For picklist fields, a list of available values (up to 255 characters for each value).
For picklists, optionally choose to alphabetize the picklist entries. You can also set the first value as the default selection. If you select both options, Salesforce alphabetizes the entries and then sets the first alphabetized value as the default.
For multi-select picklists, enter a list of values, select the sorting options that apply, and then enter how many values you want displayed at a time on edit pages.
The number of values determines the box height.
Auto-Number Formatting Examples
Use these examples when setting the display format for auto-number fields.
Format
{0}
{000}
Sample- {00000}
Displayed Values
3 66 103
003 066 103
Sample- 00003 Sample- 00666 Sample- 10023
147
Extend Salesforce with Clicks, Not Code Customize Fields
Format
Value- {00} {MM} {DD} {YY}
PO #{0} {MM}-{DD}-{YY}
Displayed Values
Value- 03 12 02 04 Value- 76 03 03 04 Value- 123 11 09 04
PO #12233 12-20-04 PO #25 06-07-04 PO #3 07-07-04
SEE ALSO:
Create a Many-to-Many Relationship
Object Reference for Salesforce and Force.com
Geolocation Custom Field
The geolocation custom field allows you to identify locations by their latitude and longitude and to calculate distances between locations.
You can calculate the distance between two geolocation fields, such as between a warehouse and a store. Or you can calculate the distance between a geolocation field and a pair of latitude and longitude coordinates, such as between a warehouse and 37.794016°, -122.395016°—the location also known as San Francisco. Latitude values must be within
-90
and
90
. Longitude values must be within
-180
and
180
.
EDITIONS
Available in: both Salesforce
Classic and Lightning
Experience
Available in all editions
Geolocation is a compound field that counts toward your org’s limits as three custom fields: one for latitude, one for longitude, and one for internal use. Support for the compound field (geolocation) versus the field’s components
(latitude and longitude) varies depending on the functionality you’re using in Salesforce. For example, you can create list views that show the field and its components, but you can’t select the compound geolocation field in Apex. You can run SOQL queries only on a geolocation field’s components.
Compound fields, including geolocation fields, have the following limitations.
•
Compound fields are read-only. To update field values, modify the individual field components.
•
Compound fields are accessible only through the SOAP and REST APIs. The compound versions of fields aren’t accessible anywhere in the Salesforce user interface.
•
Although compound fields can be queried with the
Location
and
Address
Apex classes, they’re editable only as components of the actual field. Read and set geolocation field components by appending “__latitude__s” or “__longitude__s” to the field name, instead of the usual “__c.” For example:
Double theLatitude = myObject__c.aLocation__latitude__s; myObject__c.aLocation__longitude__s = theLongitude;
You can’t access or set the compound value.
•
You can’t use compound fields in Visualforce—for example, in an
<apex:outputField>
. To access or update field values, use the individual field components.
•
If you select compound fields for export in the Data Loader, they cause error messages. To export values, use individual field components.
•
Custom geolocation and location fields on standard addresses aren’t supported with email templates.
•
You can’t use compound fields in lookup filters, except to filter distances that are within or not within given ranges. You can use distance lookup filters only in the Metadata API.
•
The only formula functions that you can use with compound fields are
ISBLANK
,
ISCHANGED
, and
ISNULL
. You can’t use
BLANKVALUE
,
CASE
,
NULLVALUE
,
PRIORVALUE
, or the equality and comparison operators with compound fields. The
148
Extend Salesforce with Clicks, Not Code Customize Fields equality and comparison operators include
=
and
==
(equal),
<>
and
!=
(not equal),
<
(less than),
>
(greater than),
<=
(less than or equal),
>=
(greater than or equal),
&&
(AND), and
||
(OR).
Other limitations of geolocation fields include:
•
Geolocation fields aren’t supported in custom settings.
•
Geolocation fields aren’t available in dashboards or Schema Builder.
•
Geolocation fields are available in Visual Workflow and in formula-based workflow and approvals, but they can’t be used in filter-based workflow updates and approvals.
•
DISTANCE
formulas are supported in:
–
Entry criteria for workflow rules and approval processes
–
Field update actions in workflow rules and approval processes
–
Custom validation rules
–
Lookup filters (in the Metadata API only)
•
Geolocation fields and latitude and longitude on standard addresses aren’t supported in Salesforce to Salesforce.
•
In Developer, Professional, Enterprise, Unlimited, and Performance editions, Salesforce can automatically add or update geolocation fields for Account, Contact, Lead, and WorkOrder records. To use this feature, your administrator must enable the geo clean rule for each object. For all other objects and editions, set values for latitude and longitude by using SOQL, Workbench, SOAP or REST API, or a geocoding service. You can then use address fields as locatable values. To find geocoding services, search the AppExchange.
•
Geolocation fields are supported in SOQL with the following limitations.
–
DISTANCE
and
GEOLOCATION
are supported in
WHERE
and
ORDER BY
clauses in SOQL, but not in
GROUP BY
.
DISTANCE
is supported in
SELECT
clauses.
–
DISTANCE
supports only the logical operators > and <, returning values within (<) or beyond (>) a specified radius.
–
When using the
GEOLOCATION
function in SOQL queries, the geolocation field must precede the latitude and longitude coordinates. For example,
DISTANCE(warehouse_location__c, GEOLOCATION(37.775,-122.418),
'km')
works but
DISTANCE(GEOLOCATION(37.775,-122.418), warehouse_location__c, 'km') doesn’t work.
–
Apex bind variables aren’t supported for the units parameter in
DISTANCE
or
GEOLOCATION
functions. This query doesn’t work.
String units = 'mi';
List<Account> accountList =
[SELECT ID, Name, BillingLatitude, BillingLongitude
FROM Account
WHERE DISTANCE(My_Location_Field__c, GEOLOCATION(10,10), :units) < 10];
For more information and examples, see the
Force.com SOQL and SOSL Reference
.
SEE ALSO:
149
Extend Salesforce with Clicks, Not Code Customize Fields
Manage Fields for a Specific Object
1. From the object management settings for the object whose fields you want to view, go to
Fields.
2. Click the field label.
3. To modify a custom field, add custom help text, or change the data type, click Edit.
4. If a custom field exists in a Managed - Released package, click Delete to delete the custom field component from future installations.
5. To set users’ access to the field, click Set Field-Level Security. This option is available depending on the edition that you have.
6. To view who can access the field based on permissions and record type, click View Field
Accessibility. This option is available depending on the edition that you have.
7. If the custom field is a dependent picklist, click Change next to the controlling field to edit the dependency rules.
8. To change
External ID
,
Required
, or other attributes under the General Options
section, see Custom Field Attributes
.
9. To restore the field and its data, click Undelete. This option is available only if the field has been deleted but not permanently erased. The field’s behavior may be different after restoring it. To restore the field completely, see
Manage Deleted Custom Fields .
Note:
If your organization uses person accounts, the Account Fields page lists both person account and business account fields.
Person accounts use a combination of account and contact fields. The following contact fields are available for person accounts, but not for business accounts.
•
Fields in the Account Standard Fields list that display with a person account icon.
•
Fields in the Contact Custom Fields & Relationships list.
EDITIONS
Available in: both Salesforce
Classic and Lightning
Experience
Available in: Contact
Manager, Group,
Professional, Enterprise,
Performance, Unlimited,
Developer, and
Database.com Editions
Standard fields are not available in Database.com
Salesforce Connect external objects are available in:
Developer Edition and for an extra cost in: Enterprise,
Performance, and
Unlimited Editions
SEE ALSO:
150
Extend Salesforce with Clicks, Not Code Customize Fields
Edit Custom Fields
1. From the management settings for the field’s object, go to Fields.
2. Click Edit next to the field’s name.
3. Modify the field attributes . The attributes differ depending on the field type.
If you’re editing a picklist, you can change its definition and its values. For picklist settings, see
on page 164.
To change the type of this custom field, see Change the Custom Field Type
on page 181.
4. Optionally, define custom help text for the field.
5. For lookup and master-detail relationship fields, optionally define a lookup filter.
6. For formula fields, click Next to modify the formula.
7. In Enterprise, Unlimited, Performance, and Developer Editions, click Next to set the field-level security for the field.
Note:
•
Editing fields may require changing a large number of records at once. To process these changes efficiently, your request may be queued and you may receive an email notification when the process has completed.
•
To customize the way a custom object’s related list appears on a parent record’s detail page, edit the parent record’s page layout. For example, if you want to edit which fields appear on a custom object’s related list on accounts, you would edit the account page layout.
•
You cannot change the
Field Name
if a custom field is referenced in Apex.
•
When editing fields for accounts, opportunities, cases, contacts, or custom objects, check for any criteria-based sharing rules that use the field in the rules. A field change may affect which records are shared.
EDITIONS
Available in: both Salesforce
Classic and Lightning
Experience
Available in: All Editions
Standard Objects are not available in Database.com
USER PERMISSIONS
To create or change fields:
•
Customize Application
SEE ALSO:
Find Object Management Settings
Delete Fields
1. From the management settings for the field’s object, go to Fields.
2. Click Del next to the name of the field.
3. When prompted, select the
Yes, I want to delete the custom field checkbox to confirm, and click Delete.
Deleted custom fields and their data are stored until your org permanently deletes them or 15 days has elapsed, whichever happens first. Until that time, you can restore the field and its data.
For information on restoring deleted custom fields and relationships, see Manage Deleted
EDITIONS
Available in: both Salesforce
Classic and Lightning
Experience
Available in all editions
USER PERMISSIONS
To delete custom fields:
•
Customize Application
151
Extend Salesforce with Clicks, Not Code Customize Fields
Note:
•
Before deleting a custom field, consider where it’s referenced. You can’t delete a custom field that’s referenced elsewhere. For example, you can’t delete a custom field that’s referenced by a field update or Apex.
•
You can’t delete a field if that field is being updated by a background job, such as an update to a roll-up summary field. Wait until the background job finishes, and try again.
•
When you delete a custom field, all of the field history data is deleted and changes are no longer tracked.
•
A background process periodically runs that cleans up metadata associated with deleted custom fields. This process will affect the
Last Modified Date
and
Last Modified By
fields on page layouts, record types, and custom objects.
SEE ALSO:
Find Object Management Settings
Manage Deleted Custom Fields
Deleted custom fields and their data are stored until your org permanently deletes them or 15 days has elapsed, whichever happens first. Until that time, you can restore the field and its data.
However, the field still counts against the maximum number of custom fields allowed in your organization. A deleted field also counts against any applicable limit for its field type. For example, a deleted custom roll-up summary field counts against the maximum number of roll-up summary fields for your Salesforce edition.
1. From the management settings for the field’s object, go to Fields.
2. Click Deleted Fields at the bottom of the list of custom fields and relationships. The number in parentheses indicates the total number of deleted custom fields for this object. This link only displays when you have a deleted custom field.
3. Use the list of deleted fields to perform the following actions:
EDITIONS
Available in: both Salesforce
Classic and Lightning
Experience
Available in: Contact
Manager, Group,
Professional, Enterprise,
Performance, Unlimited,
Developer, and
Database.com Editions
Page Layouts and Lead
Fields are not available in
Database.com
•
To view details about a field, click the field label.
•
To permanently remove the custom field and its data, click Erase.
•
To restore the field and its data, click Undelete. Some attributes of deleted fields are not restored automatically. To restore these attributes manually:
USER PERMISSIONS
a. Add the field to any page layouts that changed during the time the custom field was deleted. If reports and page layouts were not edited, the restored field remains on them.
b. Make the field unique if necessary. Salesforce automatically removes the unique attribute from any deleted custom field.
c. Make the field required if necessary. Salesforce automatically removes the required attribute for any deleted custom field.
To restore deleted custom fields and relationships:
•
Customize Application
To permanently delete custom fields or relationships:
•
Customize Application
d. Add the custom field to any appropriate Force.com AppExchange packages. Salesforce automatically removes deleted custom fields from packages that contain them.
e. Convert any lookup relationships to master-detail relationships if necessary. Salesforce converts all relationships to lookup relationships when they are deleted. To convert a lookup relationship to a master-detail relationship, populate all the applicable records with the appropriate data.
f.
Redefine any field dependencies
that Salesforce removed when the field was deleted.
g. Edit and save any formula fields. Saving prompts a syntax check; if necessary, resolve errors.
152
Extend Salesforce with Clicks, Not Code Customize Fields
h. Set up field history tracking if necessary. If the list of fields enabled for history tracking was modified during the deletion process, the restored field is no longer set up to track field history.
Notes on Restored Custom Fields
•
When deleted, the following characters are appended to the end of a custom field's developer name unless a deleted field already has that developer name: “_del”. These characters remain when you restore the custom field.
•
Formula fields are restored in a disabled state, which means they do not contain updated data until you edit and save them. While a formula field is disabled, “#Error!” displays in place of the formula value.
•
Restored fields do not display in search results immediately after you restore them. It can take a short time before the restored custom field and its data are available in search results.
•
Lead fields that are mapped to account, contact, or opportunity fields for lead conversion are still mapped accordingly when restored.
•
Auto number fields continue to increment after they are deleted and contain the correct values when restored.
•
Field history data for the deleted custom field is restored.
SEE ALSO:
Find Object Management Settings
Additional Custom Field Options
Changing Page Layouts
To change the location of a new custom field, edit the page layout for the appropriate tab.
Using Record Types
If your organization uses record types, edit the record type to modify which picklist values are visible for the record type.
Tracking Custom Field History
You can select which custom fields to track on the History related list of custom objects and most standard objects. All entries include the date, time, nature of the change, and who made the change. History data does not count against your organization’s storage limit.
Using the Translation Workbench
If your organization uses the Translation Workbench, notify your translators that new fields need translations.
Activity Custom Fields
Activity custom fields can apply only to tasks or only to events, or to both tasks and events. For example, you can create one
Time
Spent
field and then add it to both the event page layout and the task page layout.
Mapping Custom Lead Fields
For lead custom fields, you can click Map Lead Fields to specify which custom lead fields to map to custom account, contact, and opportunity fields during a lead conversion.
153
Extend Salesforce with Clicks, Not Code Customize Fields
Editing Rich Text Area Fields in Records
Use rich area text fields to improve the appearance of text, including adding images and hyperlinks.
Rich text area fields use the
to format content. The rich text editors for custom fields in Lightning Experience and Salesforce1 come with a few differences, as compared to rich text editors in Salesforce Classic.
EDITIONS
Available in: Salesforce1,
Salesforce Classic, and
Lightning Experience
Available in: Contact
Manager, Group,
Professional, Enterprise,
Performance, Unlimited, and Developer Editions
USER PERMISSIONS
To create or change custom fields:
•
Customize Application
•
The text alignment buttons (1) are displayed after the list and indentation buttons.
•
The Remove Formatting button (2) clears text formatting.
•
The default font family (3) is Salesforce Sans, Arial, sans-serif, instead of Arial, Verdana, Trebuchet MS, sans-serif.
•
The Undo and Redo buttons are no longer available. You can use keyboard shortcuts to undo and redo content formatting. In
Windows, undo your last action by pressing Ctrl+Z, and reverse your last undo by pressing Ctrl+Y. On Mac OS, use Cmd+Z and
Cmd+Y. Alternatively, use the Edit menu in your browser to undo or redo your changes.
Note:
We recommend using the toolbar to format your content. The rich text editor provides only a WYSIWYG interface. You can’t edit HTML tags. When you copy content from a web page or another source and paste it into the editor, unsupported tags are removed. Text that was enclosed in unsupported tags is preserved as plain text.
Implementation Tips
•
Specify the size of the editor box for a rich text field by configuring the Number of lines displayed property in the field’s setup.
•
When you view or print content, Salesforce preserves the formatted version of the rich text.
•
Searches of content that contains rich text area fields ignore images and tags.
•
Deleting a rich text area field moves it to the Deleted Fields section on the custom object or Salesforce Knowledge article types.
•
You can only convert rich text area fields into long text area fields. Any images are deleted the next time the long text area field is saved. After converting, markup is hidden in the long text area field but it is not removed from the record until you save the record.
That way, the markup can be restored if you change your mind.
•
The text part of a rich text area field counts toward data storage for the object that contains the field.
Pasting Content from External Sources
•
You can copy and paste text from external sources, such as Microsoft
®
Word, but you might have to reapply formatting.
•
JavaScript and CSS are treated as text. For example, if you’re creating an Idea through the API, the JavaScript or CSS code is removed without warning. Salesforce supports a limited number of approved HTML tags.
•
When a rich text area field is used in a formula, the HTML tags are stripped out before the formula is run.
154
Extend Salesforce with Clicks, Not Code Customize Fields
•
Rich text area fields can be filtered and summarized in reports, but HTML tags and special formatting aren’t included in report results.
For example,
<b>some</b> <i>text</i>
becomes “some text” instead of <b>some</b> <i>text</i> or some text.
•
You can use a rich text area field in a mail merge, but the HTML tags are included as text in the resulting document, and images aren’t merged.
Images in Rich Text Area Fields
•
The maximum size of an image that can be uploaded in a rich text area field is 1 MB. You can upload only
.gif
,
.jpg
, and
.png
file types.
•
To upload many images, use API version 20 or later. For more information, see the Force.com
SOAP API Developer's Guide
.
Note: When you upload images via the API, the alt
attribute isn’t populated unless you specified it separately.
•
Images uploaded within a rich text area field are extracted in your org’s weekly export and included in the exported data.
•
Images in rich text area fields count toward file storage for the object that contains the field.
•
You can’t add a hyperlink to an image.
•
You can’t upload an image to a rich text area using the
file://
protocol in the URL field. Instead, use
http:
,
https:
,
data:
,
//
,
/
, or a relative URL.
Formatting Support
The power of the rich text editor is in its WYSIWYG interface, therefore type in the editor and use the toolbar to format your content as much as you can. When you paste formatted content from another source, you can expect some formatting differences in Lightning
Experience and Salesforce1. Here are formatting considerations to look out for.
Warning: If you add a custom rich text area field in Salesforce Classic and edit it in Lightning Experience, you can also expect the formatting differences. Saving your changes in Lightning Experience overwrites the original formatting you had in Salesforce
Classic and conversely. Alternatively, you can fix some of the formatting using the toolbar or switch to Salesforce Classic to perform your edits.
Definition lists
Formatting for definition lists is preserved, but the styling appears different in Lightning Experience and Salesforce1. Definition terms are not bold.
Fonts
Pasting text with a predefined font face, color, or size converts the font
tag into a span
tag with the style
attribute.
Headings
Inline styles on h1
, h2
, h3
, h4
, h5
, and h6
tags are not supported and are ignored.
Hyperlinks
Hyperlinks always open in a new window or tab in Lightning Experience and Salesforce1. If you enter a hyperlink with a different target
value in Salesforce Classic and edit the rich text field in Lightning Experience or Salesforce1, the target
value is converted to
_blank
.
Inline styles
In Salesforce Classic, inline styles are supported on div
, span
, p
, br
, and hr
tags. In Lightning Experience and Salesforce1, inline styles are supported only on span
tags.
155
Extend Salesforce with Clicks, Not Code Customize Fields
Lists
Nesting a bulleted list within a numbered list and nesting a numbered list within a bulleted list are not supported. Nesting a numbered list within a bulleted list (4) converts the numbered list into a bulleted list (5) when it’s pasted into the editor, while nesting a bulleted list within a numbered list (6) converts the bulleted list into a numbered list (7).
Warning:
If you edit an existing rich text area field containing a nested list of a different type in Lightning Experience and
Salesforce1, the nested list is converted to the same type as its parent list as described previously. Look for continued improvements for nested lists in future releases.
Nested lists of the same type are supported. However, pasting a nested list into the editor flattens the list into one list in Lightning
Experience and Salesforce1. For example, a nested bulleted list within a bulleted list (8) becomes a single bulleted list (9) when pasted. For nested lists of the same type, as shown by (8) and (9), use the toolbar to adjust your list formatting. You can also press the Tab key or Shift+Tab to create a nested list item or remove a nested list item.
Note: In Lightning Experience and Salesforce1, pasting lists that are copied from Microsoft
®
Word is not supported and results in list items getting converted into paragraphs. Although they look visually like lists, they are pasted as p
tags.
Paragraphs
Pressing the Enter key creates a paragraph, which adds padding to the text when saved in Lightning Experience and Salesforce1.
Tables
In Salesforce Classic, Lightning Experience, and Salesforce1, pasting of tables is supported but you can edit only the content within the tables.
Text-level markup
•
Addresses with address
tags cause enclosing list formatting to be removed.
•
Nested quotes using q
tags are not supported.
•
Strikethrough text with strike
tags are converted to s
tags.
•
Teletype text with tt
tags are converted to code
tags.
This table lists supported HTML tags and formatting considerations in Lightning Experience and Salesforce1. When you edit a rich text field or paste text with unsupported tags Lightning Experience and Salesforce1, those tags are removed. Text that was enclosed in unsupported tags is preserved as plain text.
156
Extend Salesforce with Clicks, Not Code Customize Fields
HTML Tags
Supported in
Salesforce Classic
a
Supported in Custom Fields in
Lightning Experience and
Salesforce1?
Comments for Lightning Experience and Salesforce1
The target
attribute is always set to
_blank
. This tag is removed if href
has no value.
abbr acronym address
This tag is converted into an abbr
tag.
When text with this tag is nested in a list and pasted in the editor, the list tags, ol
, li
, and ul
, are removed. Some tags before the address
tag get nested in address
.
b bdo big blockquote br caption cite code col colgroup dd del dfn div dl dt em font
Consecutive block quotes are merged.
Definition terms are not bold.
h1 h2 h3 h4
Pasting text with a predefined font face, color, or size converts the font
tag into a span
tag with the style
attribute.
Inline styles on headings are not supported.
Inline styles on headings are not supported.
Inline styles on headings are not supported.
Inline styles on headings are not supported.
157
Extend Salesforce with Clicks, Not Code Customize Fields strike strong sub sup table tbody td tfoot th thead
HTML Tags
Supported in
Salesforce Classic
h5 h6 hr i img ins kbd li
Supported in Custom Fields in
Lightning Experience and
Salesforce1?
Comments for Lightning Experience and Salesforce1
Inline styles on headings are not supported.
Inline styles on headings are not supported.
ol
Pasting a nested list of the same type flattens the list into one list, for example, a nested bulleted list within a bulleted list. Use the toolbar to adjust your list formatting.
Nesting an ordered list (numbered) in an unordered list (bulleted) converts the ordered list into an unordered list.
p pre q s samp small span
Nested quotes are not supported.
This tag is nested in a p
tag, which adds extra padding around the text.
This tag is converted into an s
tag and is visually the same.
Nested
Nested sub sup
tags are merged.
tags are merged.
158
Extend Salesforce with Clicks, Not Code Customize Fields
HTML Tags
Supported in
Salesforce Classic
tr tt u ul
Supported in Custom Fields in
Lightning Experience and
Salesforce1?
Comments for Lightning Experience and Salesforce1
This tag is converted into a code
tag.
Nesting an unordered list (bulleted) in an ordered list (numbered) converts the unordered list into an ordered list.
var
SEE ALSO:
Rich Text Area Field Limitations
Keep these limitations in mind when working with rich text area fields.
EDITIONS
Rich text area fields aren’t available in self service portals and they aren’t supported for external objects. Additionally, consider the following limitations.
Character limits
Available in: Salesforce1,
Salesforce Classic, and
Lightning Experience
•
Salesforce supports up to 131,072 characters for each rich text area field, including the
HTML tags. If desired, you can set a lower limit.
•
An object can contain unlimited rich text area and long text area fields, although your edition’s limit for total custom fields allowed on an object, regardless of field type, applies.
Each object can contain 1,600,000 characters across long text area and rich text area fields.
When you create a long text area or rich text area field, you set a character limit for the
Available in: Contact
Manager, Group,
Professional, Enterprise,
Performance, Unlimited, and Developer Editions field—the maximum length of the text that can be entered. The default character limit for long text area and rich text area fields is 32,768 (32 KB). The maximum character limit for long text area and rich text area fields is 131,072 (128 KB). The minimum character limit is 256.
•
You can’t paste special characters, such as bullets or curly quotes, into a rich text field from another application. It’s best to type or paste in plain text and use the rich text editor to format it.
•
HTML code isn’t supported in the
Salesforce HTML editor . HTML code is treated as text.
Images and Hyperlinks
•
You can’t disable specific rich text area features. For example, you can't disable support for hyperlinks or images on certain fields.
•
You can’t upload an image to a rich text area using the
file://
protocol in the URL field. Instead, use
http:
,
https:
,
data:
,
//
,
/
, or a relative URL.
Reports
•
Only the first 254 characters in a rich text area or a long text area are supported with the “contains” operator in a report filter.
•
Only the first 254 characters in a rich text area or a long text area are displayed in a report. If you download the report, the entire field is available.
159
Extend Salesforce with Clicks, Not Code Customize Fields
Classic Encryption for Custom Fields
Restrict other Salesforce users from seeing custom text fields you want to keep private. Only users with the permission “View Encrypted Data” can see data in encrypted custom text fields.
EDITIONS
Note: This information is about Classic Encryption and not Shield Platform Encryption.
Implementation Notes
Available in: both Salesforce
Classic and Lightning
Experience
Before you begin working with encrypted custom fields, review these implementation notes, restrictions, and best practices.
Available in: Developer,
Enterprise, Performance,
Unlimited, and
Database.com Editions
•
Encrypted fields are encrypted with 128-bit master keys and use the Advanced Encryption
Standard (AES) algorithm. You can archive, delete, and import your master encryption key. To enable master encryption key management, contact Salesforce.
•
You can use encrypted fields in email templates but the value is always masked regardless of whether you have the “View Encrypted
Data” permission.
•
If you have created encrypted custom fields, make sure that your organization has “Require secure connections (HTTPS)” enabled.
•
If you have the “View Encrypted Data” permission and you grant login access to another user, the user can see encrypted fields in plain text.
•
Only users with the “View Encrypted Data” permission can clone the value of an encrypted field when cloning that record.
•
Only the
<apex:outputField>
component supports presenting encrypted fields in Visualforce pages.
Restrictions
Encrypted text fields:
•
Cannot be unique, have an external ID, or have default values.
•
For leads are not available for mapping to other objects.
•
Are limited to 175 characters because of the encryption algorithm.
•
Are not available for use in filters such as list views, reports, roll-up summary fields, and rule filters.
•
Cannot be used to define report criteria, but they can be included in report results.
•
Are not searchable, but they can be included in search results.
•
Are not available for: Salesforce Mobile Classic, Connect Offline, Salesforce for Outlook, lead conversion, workflow rule criteria or formulas, formula fields, outbound messages, default values, and Web-to-Lead and Web-to-Case forms.
Best Practices
•
Encrypted fields are editable regardless of whether the user has the “View Encrypted Data” permission. Use validation rules, field-level security settings, or page layout settings to prevent users from editing encrypted fields.
•
You can still validate the values of encrypted fields using validation rules or Apex. Both work regardless of whether the user has the
“View Encrypted Data” permission.
•
Encrypted field data is not always masked in the debug log. Encrypted field data is masked if the Apex request originates from an
Apex Web service, a trigger, a workflow, an inline Visualforce page (a page embedded in a page layout), or a Visualforce email template. In other cases, encrypted field data isn’t masked in the debug log, like for example when running Apex from the Developer
Console.
160
Extend Salesforce with Clicks, Not Code Customize Fields
•
Existing custom fields cannot be converted into encrypted fields nor can encrypted fields be converted into another data type. To encrypt the values of an existing (unencrypted) field, export the data, create an encrypted custom field to store that data, and import that data into the new encrypted field.
•
Mask Type
is not an input mask that ensures the data matches the
Mask Type
. Use validation rules to ensure that the data entered matches the mask type selected.
•
Use encrypted custom fields only when government regulations require it because they involve more processing and have search-related limitations.
Note:
This page is about Classic Encryption, not Shield Platform Encryption. What's the difference?
SEE ALSO:
Time Custom Field (Beta)
Track time, unbound to a date, with this custom field type. The time type is useful for time management, event planning, and project management.
Note: This release contains a beta version of the time custom field type, which means it’s a high-quality feature with known limitations. This feature appears in sandbox and developer edition orgs. For information on enabling this feature in your production org, contact Salesforce. We can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only based on generally available products and features. You can provide feedback and suggestions for the time field type in the Custom Time Field Success Community group .
You can select the time field type when you create a custom field. The time type is a timestamp without the date included. Use the time field type when you require a time of day that is not specific to a single date. For example, use it to display business hours, or if you want to compare times of the day to calculate a duration.
Time Field Format
The display and management of time field values observes the following behaviors.
•
The time custom field type uses a 24-hour notation. You can save a time value in HH:MM, for example, 14:40.
•
Salesforce Classic: A time field displays a value based on your organization’s Locale setting on the Company Information page in
Setup.
•
Lightning Experience, Quick Actions and the Salesforce1 mobile browser app: A time field displays GMT, always.
•
In Reports, time field values display as numbers.
•
In formulas, get a time value from the
TIMEVALUE
function. The new
TIMENOW
,
HOUR
,
MINUTE
,
SECOND
, and
MILLISECOND functions are also useful for working with time in formulas.
•
You can define a default value for a time field, and you can use a formula for the default value.
•
The time field type is represented in the Metadata API as a FieldType enumeration value.
Time Field Limitations
Be aware of the following limitations when using a time field type. The time field:
•
Cannot be added to records in Automated flows created in Cloud Flow Designer or processes designed in Process Builder.
•
Is not supported in Schema Builder.
•
Does not have an Aura UI component.
161
Extend Salesforce with Clicks, Not Code Customize Fields
•
Cannot be converted to the text or number types.
•
Doesn't support the creation of custom index for SOQL queries.
•
Is not available for standard lookup relationships in external objects.
Time Data Type and Functions
This beta release also introduces the Time data type and the following new functions for working with time in formulas.
HOUR
Description:
Use:
Examples:
Returns the local time hour value without the date in the form of a number from 1 through 12.
HOUR( time)
and replace
time
with a time value or value such as
TIMENOW()
.
HOUR(TIMEVALUE(ClosedDate))
displays only the hour in a time field based on the value of the Time Closed field.
HOUR("17:30:45.125")
returns 17.
MILLISECOND
Description:
Use:
Examples:
Returns a milliseconds value in the form of a number from 0 through 999.
MILLISECOND( time)
and replace
time
with a time value or value such as
TIMENOW()
.
MILLISECOND(TIMEVALUE(ClosedDate))
displays only the milliseconds in a time field based on the value of the Time Closed field.
MILLISECOND("17:30:45.125")
returns 125.
MINUTE
Description:
Use:
Examples:
Returns a minute value in the form of a number from 0 through 60.
MINUTE( time)
and replace
time
with a time value or value such as
TIMENOW()
.
MINUTE(TIMEVALUE(ClosedDate))
displays only the minutes in a time field based on the value of the Time Closed field.
MINUTE("17:30:45.125")
returns 30.
SECOND
Description:
Use:
Returns a seconds value in the form of a number from 0 through 60.
SECOND(
time)
and replace
time
with a time value or value such as
TIMENOW()
.
162
Extend Salesforce with Clicks, Not Code
Examples:
Customize Fields
SECOND(ClosedDate)
displays only the seconds in a time field based on the value of the Time
Closed field.
SECOND("17:30:45.125")
returns 45.
TIMENOW
Description:
Use:
Example:
Tips:
Returns a time value in GMT representing the current moment. Use this function instead of the NOW function if you only want to track time, without a date.
TIMENOW()
IF(ISPICKVAL( Rating , "Hot"), TIMENOW(), TIMEVALUE(CreatedDate))
This formula checks to see if a lead is rated “Hot” and if so, returns the current time; otherwise it returns the time since someone created the lead.
•
Do not remove the parentheses.
•
Keep the parentheses empty. They do not need to contain a value.
•
Use
TODAY if you prefer to use a date field.
•
The displayed value is based on the organization’s Locale settings.
TIMEVALUE
Description:
Use:
Examples:
Tips:
Returns the local time value without the date, such as business hours.
TIMEVALUE(
value)
and replace
value
with a date/time or text value, merge field, or expression.
TIMEVALUE(ClosedDate)
displays a time value based on the value of the Date/Time Closed field.
TIMEVALUE("17:30:45.125")
returns 5:00 PM.
•
The displayed value is based on the organization’s Locale settings.
SEE ALSO:
Formula Operators and Functions
Using Date and Date/Time Values in Formulas
163
Extend Salesforce with Clicks, Not Code Customize Fields
Add or Edit Picklist Values
Add or edit values in a custom picklist from the fields area of an object. If the picklist uses a global picklist value set, you can change its values only by editing the global value set. Your changes affect all picklists that inherit their values from that global value set.
EDITIONS
Note: Changes to picklist values are logged in Setup Audit Trail. To view the audit history:
From Setup, enter
View Setup Audit Trail
in the
Quick Find
box, then select
View Setup Audit Trail.
1. Navigate to the fields area for your object.
2. In the Custom Fields & Relationships related list, click the name of the picklist field to update.
3. In the Values section, click Edit next to a value.
Available in: both Salesforce
Classic and Lightning
Experience
Available in all editions
USER PERMISSIONS
To change picklists:
•
Customize Application
4. Change the value’s name, and optionally make the value the default for the master picklist.
5. Assign a color to use in charts by clicking the
button and selecting how to assign colors to values.
•
Assign fixed colors to all values assigns a fixed color to each value from the standard set of chart colors. The Chart Colors column shows the assigned colors. For example, if you want Closed Lost values always to be red in charts grouped by Opportunity
Stage, assign red to that picklist value.
•
Assign colors to values dynamically assigns colors when a chart is generated. For example, if you need only certain picklist values to have fixed colors in charts, manually assign colors to those values and leave the rest to be assigned dynamically.
Note: Chart colors aren’t available for multi-select picklists, currency picklists, or Task Subject, Event Subject, Knowledge
Validation Status, and Opportunity Competitor picklists.
Tip:
•
If you use record types, changing the default value of the master picklist doesn’t affect the default value of the picklist for a record type.
•
For Ideas, setting the default value of the Categories or Status picklists doesn’t affect the default value on the Ideas pages.
•
If you change the label for a picklist value that’s used as a filter criterion, the picklist value is automatically removed from the filter criteria. For example, if your report contains a filter where
Lead Source equals Email or Web
and you change the picklist value Web to Referral, your report filter changes to
Lead Source equals Email
. If the changed picklist value was the only value specified for a particular filter, it continues to show up in your filters, but an error appears.
6. Click Save.
7. To make the picklist required (if it’s not already), click Edit at the top of the detail page, and check Always require a value in this
field in order to save a record.
8. To change the picklist from unrestricted to restricted or vice-versa, adjust the Restrict picklist to the values defined in the value
set setting.
9. To open an easy-to-print list of your picklist values, click Printable View.
Note:
If your org uses the Translation Workbench, notify your translators that the translations can be outdated when you change picklist values.
Picklists with Additional Information
164
Extend Salesforce with Clicks, Not Code Customize Fields
As your business needs change, replace picklist values with more relevant alternatives. Replacing a value globally replaces that field value on all existing records.
Remove or replace custom picklist values to update the records that have the picklist field.
Protect Picklist API Names for Formulas and Integrations
When you create a picklist value, an API Name that matches the Label is assigned. By default, the API Name can be changed at any time, but you can choose to protect the API Name.
Manage Inactive Picklist Values
Deactivate, reactivate, or remove a value from a restricted or unrestricted custom picklist. If it’s a global picklist value set, these actions simultaneously update all custom picklists that inherit its value set.
SEE ALSO:
Manage Inactive Picklist Values
Manage Inactive Picklist Values
Protect Picklist API Names for Formulas and Integrations
Picklists with Additional Information
These standard picklist fields have additional information that you can edit.
Picklist
Partner Role
(for accounts)
Priority
(for cases)
Description
Roles of account partners, for example, Consultant, Supplier. These options are available when you add an account to the Partners related list of an account or opportunity.
To edit, from Setup, enter
Partner Roles
in the
Quick
Find
box, then select Partner Roles.
Enter the name of the partner role in the “Role” column. In the
“Reverse Role” column, enter the corresponding reverse partner role. Assigning a partner role to an account creates a reverse partner relationship so that both accounts list the other as a partner.
Each role and reverse role value can have up to 40 characters.
Urgency of case, for example, Low, High.
If you delete a value, you have the option to map the deleted value to another existing value in all your org’s cases.
Each picklist value can have up to 40 characters.
165
Extend Salesforce with Clicks, Not Code
Picklist
Status
(for campaign members)
Status
Status
(for cases)
(for contracts)
Contact Role
Lead Status
(for contracts)
(for leads)
Contact Role
(for opportunities)
Customize Fields
166
Description
State of a campaign member, for example, Sent or Responded.
If you delete a Status value, you have the option to map the deleted value to another existing value. The new replacement value is automatically added to the member status for campaigns that contained the deleted value.
If the deleted value is the default member status for a campaign, the new replacement value becomes the default status for that campaign.
State of case, for example, New, On Hold.
If you delete a value, you have the option to map the deleted value to another existing value in all your org’s cases.
Each picklist value can have up to 40 characters.
State of the contract in the contract business process. You can add values to this picklist and organize each value into one of several categories, for example, “Draft”, “In Approval Process”, or
“Activated”. Then sort your contracts using these categories in reports and views.
Role of a contact on a contract, for example, Business User, Decision
Maker. These options are available when you add a contact to the
Contact Roles related list of a contract.
To edit, from Setup, enter
Contact Roles
in the
Quick
Find
box, then select Contact Roles on Contracts.
Each picklist value can have up to 40 characters.
State of the lead, for example, Open, Qualified.
Select one value as the “Default Status” assigned to all new leads created manually, via imports, or via your website. Select one or more values as the “Converted Status” assigned to converted leads.
When you convert qualified leads into an account, contact, and opportunity, you can select one of the “Converted” statuses to assign to the lead. Leads with a “Converted” status type are no longer available in the Leads tab, although you can include them in reports.
If you delete a value, you have the option to map the deleted value to another existing value in all your org’s leads.
Each value can have up to 20 characters.
Role of a contact for an opportunity, for example, Business User,
Decision Maker. These options are available when you add a contact to the Contact Roles related list of an opportunity.
To edit, from Setup, enter
Contact Roles
in the
Quick
Find
box, then select Contact Roles on Opportunities.
Extend Salesforce with Clicks, Not Code
Picklist
Stage
(for opportunities)
Status
Status
SEE ALSO:
(for solutions)
Priority
(for tasks)
(for tasks)
Task Type
(for tasks)
167
Customize Fields
Description
Each picklist value can have up to 40 characters.
Sales process stages, for example, Prospect, Proposal. This picklist also affects the
Type
and
Forecast Category
values of an opportunity. Specifically, changing the
Type
or
Forecast
Category
for a
Stage
picklist value updates all opportunities that have that stage value.
To edit, from the management settings for opportunities, go to
Fields, and then click Edit next to Stage.
To deactivate an active stage, click Del next to the stage. On the mapping page, don't replace the stage with another existing value; just click Save. The stage now appears in the Inactive Stage Picklist
Values related list. The stage is no longer in use but can exist in older opportunity records.
Status of a solution, for example, Draft, Reviewed. Mark one or more values as “Reviewed”. When users solve cases using solutions, they can view which solutions have been reviewed and which have not.
Each picklist value can have up to 40 characters.
Importance of the task, for example, High, Normal, Low. Set one value as the default priority of all new tasks, and one value as the highest priority.
If you delete a value, you have the option to map the deleted value to another existing value in all your org’s tasks.
Each picklist value can have up to 20 characters.
State of a task, for example, Not Started, Completed. Choose at least one value as the “Closed” status and one value as the “Default” status for all new tasks.
If you delete a value, you have the option to map the deleted value to another existing value in all your org’s tasks.
Each picklist value can have up to 40 characters.
Send Email Default
specifies the default task type assigned when the task is sending email or mass email, and when tasks are created via inbound email, such as Email to Salesforce.
Default specifies the default picklist value when creating tasks.
To edit, from the management settings for tasks, go to Fields, and then click Edit next to the picklist value that you want to specify as the default.
Extend Salesforce with Clicks, Not Code Customize Fields
Picklist Limitations
The maximum number of characters you can have in a picklist depends on the type of picklist. Each value in a picklist includes a line break and a return character that aren’t visible. These two additional characters per value are counted as part of the character limit for each value.
Additional limits apply to both standard and custom picklists.
Additional Limits for Standard Picklists
For standard picklists, each value can have up to 255 characters, not including line breaks and returns. This applies to single-select and multi-select picklists.
Picklist Field
Lead Status
Task Status
Task Priority
Case Status
Case Priority
Opportunity Stage
50
100
50
100
Maximum Number of Values
100
100
EDITIONS
Available in: both Salesforce
Classic and Lightning
Experience
Available in: All Editions
Standard Picklists are not available in Database.com
USER PERMISSIONS
To change picklists:
•
Customize Application
Limits for Custom Picklists
Custom single-select picklists can have:
•
Up to 1,000 values
•
Up to 255 characters per value
Custom multi-select picklists can have:
•
Up to 500 values
•
Up to 255 characters per value
Users can select up to 100 values at a time on a record.
You can have up to 500 picklist global value sets in an org. Each global value set, or restricted picklist, can contain a mix of 1,000 active and inactive values. Unrestricted picklists can have up to 1,000 active values. There’s no limit on the number of custom picklists that use global picklist value sets.
Functional Limitations for Custom Picklists
•
You can make a custom picklist field into a restricted picklist only if the picklist has fewer than 1,000 values (or entries). A restricted picklist’s values are limited to only those values defined by a Salesforce admin. This prevents users from loading redundant or erroneous values through the API.
•
Global picklist value sets are always restricted picklists. This is a good thing, as it preserves data integrity. (Global value sets are shared across objects. Reuse the value set for any custom picklist field.)
•
For custom picklist fields that use a global picklist value set, you can change from a single-select to multi-select picklist and vice versa. However, you can’t change the picklist to a different field type such as checkbox, currency, or text.
168
Extend Salesforce with Clicks, Not Code Customize Fields
Replace Picklist Values
As your business needs change, replace picklist values with more relevant alternatives. Replacing a value globally replaces that field value on all existing records.
For example, let’s say you have a status picklist with three different closed values, Closed-red,
Closed-yellow, and Closed-green, and you want to simplify those to just one value. Replace them with the new value Closed.
Important: If you replace a parent value in a controlling picklist, the picklist dependency on
that value is lost. After replacing the parent value, re-create the dependency using the new
parent value.
1. If necessary, create the replacement value in the picklist edit page. See Add or Edit Picklist
.
2. Navigate to the picklist.
EDITIONS
Available in: both Salesforce
Classic and Lightning
Experience
Available in all editions
USER PERMISSIONS
To replace picklist values:
•
Customize Application
•
For a global picklist value set: From Setup, enter
picklist
in the
Quick Find
box, then select Picklist Value Sets.
•
For a picklist on an object, go to the fields area of the object. For example, for an Account picklist: From Setup, enter
Account
in the
Quick Find
box, then select Fields under Accounts.
3. Start the picklist value replace process.
•
For a global picklist value set: Go to the Global Value Set Detail page by clicking the picklist name. In the Values section, click
Replace.
•
For all other picklists: Click Replace next to the picklist name.
4. Enter the value to change, and select a new replacement value.
Note: Replacing an existing picklist value also changes the
Modified By
date and time for the record.
5. To use the new value in records where this field is currently empty, select
Replace all blank values
.
6. To update all occurrences of the value in your org’s records with the new value, click Replace. Occurrences in the Recycle Bin are also updated.
Your replace job is queued. To check the job’s status, from Setup, enter
Background Jobs
in the
Quick Find
box, then select
Background Jobs. You receive an email when the job is complete.
Note: If you replace the Stage picklist for opportunities, the
Probability
,
Forecast Category
, and
Expected
Revenue
fields are also updated with the corresponding values.
SEE ALSO:
Create a Global Picklist Value Set
Protect Picklist API Names for Formulas and Integrations
Manage Inactive Picklist Values
Remove a Picklist Value
Remove or replace custom picklist values to update the records that have the picklist field.
169
Extend Salesforce with Clicks, Not Code Customize Fields
You have several ways to remove existing picklist field values. And, the steps are a little different when your picklist values are part of a global picklist value set. While you remove them, you can also to replace them with another value. For more information on replacing
an existing value, see Replace Picklist Values
. The following steps remove existing values.
1. Navigate to the picklist.
•
For a global picklist value set: From Setup, enter
picklist
in the
Quick Find
box, then select Picklist Value Sets.
•
For a picklist on an object, go to the fields area of the object. For example, for an Account picklist: From Setup, enter
Account
in the
Quick Find
box, then select Fields under Accounts.
2. Click the picklist name.
3. To remove a value from the picklist, click Del next to the value’s name.
Decide whether to replace the value or leave it blank. If you replace it with a blank value, existing records will not display the value anymore. To keep the value on existing records, use Deactivate, instead of Del.
Note:
Some special picklists, such as opportunity
Stage
,
Task Priority
,
Task Status
,
Lead Status
, and
Case Status, prompt you to map the deleted value to another existing value in all your org’s records. You can map the values or leave your existing data unchanged.
Using the option to replace a picklist value while deleting the current value does not trigger workflow rules.
For orgs using record types, include some or all the values from the master picklist in different record types to offer a subset of values to users based on their profile.
Protect Picklist API Names for Formulas and Integrations
When you create a picklist value, an API Name that matches the Label is assigned. By default, the
API Name can be changed at any time, but you can choose to protect the API Name.
A picklist value is identified by either the displayed value or the API Name. Formulas reference the
API Name so that the formula continues to work even if the displayed value changes. An admin can prevent changes to the API Name to protect the references to the fields in formulas or during integrations, such as data import.
1. From Setup, enter
picklist
in the Quick Find box, then select Picklist Settings.
2. To prevent changes to the API names for any of the values, select Disable editing picklist
values' API names.
If you need to change an API Name later, you can deselect this option.
EDITIONS
Available in: both Salesforce
Classic and Lightning
Experience
Available in all editions
USER PERMISSIONS
To customize picklist settings:
•
Customize Application
SEE ALSO:
Create a Custom Picklist Field
170
Extend Salesforce with Clicks, Not Code Customize Fields
Sort Picklists
1. From the management settings for the picklist field’s object, go to Fields.
EDITIONS
Note:
•
For custom task or event fields, go to the object management settings for Activities.
•
For standard task fields, go to the object management settings for Tasks. For standard event fields, go to the object management settings for Events.
•
For Knowledge validation status picklists, from Setup, enter
Validation
Statuses
in the
Quick Find
box, then select Validation Statuses.
Available in: both Salesforce
Classic and Lightning
Experience
Available in all editions
USER PERMISSIONS
2. Click the name of the picklist to update.
3. Click Reorder.
To sort picklists:
•
Customize Application
4. Use the arrows to arrange the field in the proper sequence.
5. Select a default value if desired.
6. To alphabetize the entries for users on edit pages, check Sort values alphabetically.... The entries always appear in alphabetical order, regardless of the user’s language.
7. Save your changes.
Note: On record edit and detail pages and in reports, picklist and multi-select picklist fields can include inactive values. These inactive values are sorted last, unless you’ve chosen alphabetical sorting. In that case, all values are sorted alphabetically.
SEE ALSO:
Find Object Management Settings
Manage Inactive Picklist Values
Deactivate, reactivate, or remove a value from a restricted or unrestricted custom picklist. If it’s a global picklist value set, these actions simultaneously update all custom picklists that inherit its value set.
Note:
Only a Salesforce admin can modify the values of a restricted picklist. Users can’t add unapproved values, even through the API.
You can’t deactive unrestricted picklist values for the Task.Subject or Event.Subject fields. The picklist values are deleted instead of deactivated.
EDITIONS
Available in: Salesforce
Classic and Lightning
Experience
Available in: All Editions
1. Navigate to the picklist you want to modify.
•
For a picklist on an object, go to the fields area of the object.
•
For a global picklist: From Setup, enter
picklist
in the
Quick Find
box, then select
Picklist Value Sets.
USER PERMISSIONS
To create or change custom fields:
•
Customize Application
2. Go to the picklist’s detail page by clicking the picklist’s name.
3. In the Values section, modify the picklist value.
•
To deactivate a value, which removes it from the picklist but keeps it on existing records: Click Deactivate next to the value’s name. The value moves to the Inactive Values section. If you need the value again later, click Activate next to its name.
•
To remove a value from the picklist and all records that use it: Click Del next to the value’s name and select Replace value on
records with blank value. Then click Save.
171
Extend Salesforce with Clicks, Not Code Customize Fields
•
To remove a value from a global picklist and any custom picklists that share its value set: Click Del next to the value’s name and then click OK. If any custom picklists use this global picklist value set, you’re prompted to replace the value with either a blank value or an existing, active value. If no custom picklists use the value set, the value is deleted from the global picklist.
Note: If a global picklist value is used in historical trending, it’s deactivated but not deleted.
Deleting a value in a global picklist value set or on non-global, restricted picklists goes to the background jobs queue. When the job completes, your picklist is updated and you’re notified by email.
Changes to picklist values are logged in Setup Audit Trail. To view the audit history: From Setup, enter
View Setup Audit Trail
in the
Quick Find
box, then select View Setup Audit Trail.
Using the option to replace a picklist value while deleting the current value does not trigger workflow rules.
Define Dependent Picklists
Tip: If your org uses record types, make sure that your controlling and dependent picklist values are available in the appropriate record types before defining a dependent picklist.
1. From the management settings for the object you want to add a field to, go to Fields.
Custom task and event fields are accessible from the object management settings for Activities.
2. Click Field Dependencies.
3. Click New.
4. Choose a controlling field and dependent field.
EDITIONS
Available in: both Salesforce
Classic and Lightning
Experience
Available in: All Editions
Standard Objects are not available in Database.com
Note: Some picklist and checkbox fields may not be available as controlling fields.
USER PERMISSIONS
5. Click Continue.
6. Use the field dependency matrix to specify the dependent picklist values that are available
when a user selects each controlling field value.
To define dependent picklists:
•
Customize Application
7. Optionally, click Preview to test your selections. If your organization uses record types, choose a record type to test how it affects your controlling and dependent picklist values. The record type controls what values are available in the controlling field. The record type and the controlling field together determine what values are available in the dependent picklist. For example, a dependent value is only available if it is available in the selected record type and the selected controlling value.
Note: The
Filter by Record Type
option doesn’t appear in the Preview window for activity custom fields.
8. Click Save.
Using the Field Dependency Matrix
Dependent Picklist Considerations
172
Extend Salesforce with Clicks, Not Code Customize Fields
Dependent Picklists
Use dependent picklists to help your users enter accurate and consistent data. A dependent picklist is a custom or multi-select picklist for which the valid values depend on the value of another field, called the controlling field. Controlling fields can be any picklist (with at least one and fewer than
300 values) or checkbox field on the same record.
EDITIONS
Available in: both Salesforce
Classic and Lightning
Experience
For example, you can define a
Reason
custom picklist on opportunities and make its valid values depend on the value of the
Stage
picklist as follows:
Available in all editions
•
If
Stage
is
Closed Won
, the valid values for
Reason
are
Superior features
or
Lower price
.
•
If
Stage
is
Closed Lost
, the valid values for
Reason
are
Inferior features
,
Higher price
, or
Company viability
.
SEE ALSO:
Dependent Picklist Considerations
Using the Field Dependency Matrix
The field dependency matrix lets you specify the dependent picklist values that are available when a user selects each controlling field value. The top row of the matrix contains the controlling field values, while the columns list the dependent field values.
EDITIONS
Use this matrix to include or exclude values. Included values are available in the dependent picklist when a value in the controlling field is selected. Excluded fields are not available in the dependent picklist for the selected controlling field value.
Available in: both Salesforce
Classic and Lightning
Experience
Available in all editions
To include or exclude values:
•
Double-click values to include them. Included values are indicated with highlighting. Double-click any highlighted values to exclude them.
•
Click a value and use SHIFT+click on another value to select a range of adjacent values. Then click Include Values to make the values available, or Exclude Values to remove them from the list of available values.
USER PERMISSIONS
To define picklist dependencies:
•
Customize Application
•
Click a value and use CTRL+click to select multiple values. Then click Include Values to make the values available, or Exclude Values to remove them from the list of available values.
•
Click a column header to select all the values in that column. Then click Include Values to make the values available, or Exclude
Values to remove them from the list of available values.
To change the values in your view:
•
Click View All to view all available values at once.
•
Click Go To and choose a controlling value to view all the dependent values in that column.
•
Click Previous or Next to view the values in columns that are on the previous or next page.
•
Click View sets of 5 to view 5 columns at a time.
173
Extend Salesforce with Clicks, Not Code Customize Fields
Edit Dependent Picklists
1. From the management settings for the picklist’s object, go to Fields.
2. Click Field Dependencies.
3. Click Edit next to the field dependency relationship you want to change.
4. Use the field dependency matrix to specify the dependent picklist values that are available
when a user selects each controlling field value.
5. Optionally, click Preview to test your selections.
6. Save your changes.
SEE ALSO:
Find Object Management Settings
Delete Picklist Dependencies
If you no longer want the values of a dependent picklist to depend on a controlling field, delete its dependency. Deleting the dependency removes the logic that defines how the values of the picklist depend on the controlling field, but doesn't delete the fields or affect their data.
1. From the management settings for the picklist’s object, go to Fields.
2. Click Field Dependencies.
3. Click Del next to the field dependency relationship you want to delete.
4. Click OK to confirm.
SEE ALSO:
Find Object Management Settings
EDITIONS
Available in: both Salesforce
Classic and Lightning
Experience
Available in all editions
USER PERMISSIONS
To edit field dependencies:
•
Customize Application
EDITIONS
Available in: both Salesforce
Classic and Lightning
Experience
Available in all editions
USER PERMISSIONS
To delete picklist dependencies:
•
Customize Application
Dependent Picklist Considerations
Consider the following when defining dependent picklists:
Checkboxes
Checkbox fields can be controlling fields but not dependent fields.
Converting fields
When you convert existing fields to dependent picklists or controlling fields, it doesn’t affect the existing values in your records. After conversion, the dependency rules apply to new records and to any changes to existing records.
Default values
You can set default values for controlling fields but not for dependent picklists.
Field-level security
Field-level security settings for a controlling field and dependent picklist are independent.
Remember to hide a controlling field whenever its correlating dependent picklist is hidden.
Import
The Data Import Wizard doesn’t consider field dependencies. You can import any value into a dependent picklist regardless of the value imported for a controlling field.
EDITIONS
Available in: both Salesforce
Classic and Lightning
Experience
Available in: All Editions
Page Layouts and Leads are not available in
Database.com
USER PERMISSIONS
To define and edit dependent picklists:
•
Customize Application
174
Extend Salesforce with Clicks, Not Code Customize Fields
Lead conversion
If you create a dependency for lead fields that map to account, contact, and opportunity fields for lead conversion, create the same dependency on the account, contact, or opportunity.
Dependent picklists and controlling lead fields can be mapped to account, contact, or opportunity fields with different dependency rules.
Multi-select picklists
Multi-select picklists can be dependent picklists but not controlling fields.
Standard versus custom picklists
Custom picklist fields can be either controlling or dependent fields.
Standard picklist fields can be controlling fields but not dependent fields.
Picklist limitations
A controlling field can have up to 300 values. If a field is both a controlling field and dependent picklist, it can’t contain more than
300 values.
The following fields are not available as controlling fields.
Activity Fields
Call Type
Create recurring series of events
Show Time As
Subject
Task
Type
Contact Fields
Salutation
Contact Currency
Custom Object Fields
Currency
Lead Fields
Converted
Unread By Owner
Dependency limitations
Before defining a dependency, make sure that your picklist has at least one value. Standard fields like
Product Family
do not contain values until you add them.
If a standard controlling field relies on functionality that your organization decides to disable, the dependency rules for the picklist go away. For example, if your organization disables the Self-Service portal and the
Closed by Self-Service User
is a controlling field, its dependent picklist displays all available values.
If you replace a parent value in a controlling picklist, the picklist dependency is lost. After replacing the parent value, re-create the dependency using the new parent value.
Connect Offline
While controlling fields and dependent picklists are available in Connect Offline, the logic between them is not.
175
Extend Salesforce with Clicks, Not Code Customize Fields
Page layouts
Page layouts that contain dependent picklists must also contain their controlling picklist fields, or the dependent picklist values don't display.
For visually impaired users, make sure that the dependent picklist is lower on the page layout than its controlling field.
If a dependent picklist is required and no values are available for it based on the controlling field value, users can save the record without entering a value. The record is saved with no value for that field.
Record types
You can define or change the record type for your dependent picklist only within the Preview dialog when creating or editing the field dependency values. The record type controls what values are available in the controlling field. The record type and the controlling field together determine what values are available in the dependent picklist. For example, a dependent value is only available if it is available in the selected record type and the selected controlling value.
Rich Text Editor
Use the rich text editor to format text in custom fields with the rich text area type and in many other features, such as Chatter publisher and groups.
Available in: Salesforce1, Salesforce Classic, and Lightning Experience
Available in: All Editions
You can perform the following operations with the rich text editor’s WYSIWYG interface.
•
Format text as bold, italicized, underlined, or strikethrough
•
Create bulleted and numbered lists
•
Change paragraph indentation
•
Insert a hyperlink
•
Insert an image
•
Remove formatting
The availability of toolbar buttons varies across features. For example, the code snippet button is available in Chatter publisher but not in custom fields.
Note: In Summer ’17, custom fields provide a rich text editor that no longer uses CKEditor in Lightning Experience and Salesforce1.
Rich text editors provide a WYSIWYG interface only; you can’t edit HTML tags. When you copy content from a web page or another source and paste it into the editor, unsupported tags are removed. Text that was enclosed in unsupported tags is preserved as plain text. You aren’t notified when unsupported or potentially malicious HTML tags are removed. You can expect minor formatting or styling differences when editing a rich text field across the interfaces. We recommend using the toolbar to fix formatting or styling differences.
Some features have rich text editors across Salesforce Classic, Lightning Experience, and Salesforce1. For example, the Information field in groups provides a rich text editor in all three user interfaces, but Chatter Publisher has a rich text editor only in Salesforce Classic and
Lightning Experience.
Salesforce Classic Lightning Experience Salesforce1
Groups
176
Extend Salesforce with Clicks, Not Code
Salesforce Classic Lightning Experience Salesforce1
Customize Fields
Lightning Components
( ui:inputRichText
and lightning:inputRichText
)
Custom Fields
Chatter Publisher
Knowledge Article
Lightning App Builder (Rich Text
Component)
Community Builder (Rich
Content Editor)
Visual Workflow
Idea Themes
Send Email Action
Sales Path
Notes
Note:
, use dropdown lists, or select colors for text or background. To use the rich text editors, make sure that JavaScript is enabled in your browser.
Rich Text Editor Considerations
When you use the editor, note the following.
•
The maximum number of characters you can enter in the rich text editor is equal to the field length specified when creating or editing the field. The default is 32,768 characters.
•
Clicked hyperlinks open in a new browser window. The rich text editor supports HTTP, HTTPS, and mailto hyperlinks.
•
The rich text editor doesn’t validate hyperlinks to web pages. Confirm that you are specifying a valid URL.
•
To insert an image, click and either select:
–
Web Address and enter the URL of the image.
–
Upload Image and select an image from your local host. You can upload only JPEG, PNG, or GIF files. The file cannot exceed 1
MB. You can’t add a hyperlink to an image.
Optionally, enter a description that appears when you hover over the image. The image must have a URL that Salesforce can access.
•
The rich text editor supports all languages that Salesforce Knowledge supports.
•
The rich text editor does not support JavaScript or Cascading Style Sheets (CSS).
•
The rich text editor is disabled for users who have accessibility mode enabled. It’s replaced with a text field.
177
Extend Salesforce with Clicks, Not Code Customize Fields
<a>
<abbr>
<acronym>
<address>
<b>
<bdo>
<big>
<blockquote>
<br>
<caption>
<cite>
<code>
<col>
<colgroup>
<dd>
<del>
<dfn>
<div>
<dl>
Supported Formatting
We recommend that you use the toolbar to format your content. When you copy content from a web page or another source and paste it into the editor, unsupported tags are removed. Text that was enclosed in unsupported tags is preserved as plain text. The rich text editor supports the tags listed in the table.
<dt>
<em>
<font>
<h1>
<h2>
<h3>
<h4>
<h5>
<h6>
<hr>
<i>
<img>
<ins>
<kbd>
<li>
<ol>
<p>
<pre>
<q>
<samp>
<small>
<span>
<strike>
<strong>
<sub>
<sup>
<table>
<tbody>
<td>
<tfoot>
<th>
<thead>
<tr>
<tt>
<ul>
<var>
Note: Rich text editors in custom rich text area fields have minor formatting differences in Lightning Experience and Salesforce1, as compared to Salesforce Classic. For more information, see
Editing Rich Text Area Fields in Records .
The tags can include the following attributes.
alt background border class colspan face height href name rowspan size src style target width
178
Extend Salesforce with Clicks, Not Code Customize Fields
The following URL protocols are supported.
•
http:
•
https:
•
file:
•
ftp:
•
mailto:
•
#
•
/
for relative links
Rich Text Editors Using CKEditor
Rich text editors in Salesforce Classic continue to use CKEditor. In Lightning Experience and Salesforce1, the following features have rich text editors that continue to use CKEditor.
•
Email Composer, using the Send Email action
•
Lightning Knowledge
•
Lightning App Builder
•
ui:inputRichText
component
Note:
The ui:inputRichText
component is no longer supported for LockerService. Use lightning:inputRichText instead.
These features load the rich text editor in an iframe, which means that they don’t load correctly if your browser doesn’t have the appropriate security settings. Refer to your browser’s instructions to configure the settings. For example, in Internet Explorer, make sure that the
Launching programs and files in an IFRAME security setting is set to Enable or Prompt. In Safari, we recommend changing your
Privacy settings for cookies to Allow from websites I visit. In Chrome, make sure that Block third-party cookies and site data is not selected in the Content settings.
Additionally, to start typing in the rich text editor on Internet Explorer 11 on touch-enabled devices running Windows, you must click the rich text area field and tab into the editor first.
Add Videos Using the HTML Editor
You can paste code samples into your posts in Chatter Answers and Ideas.
SEE ALSO:
Editing Rich Text Area Fields in Records
Add Videos Using the HTML Editor
Available in:Salesforce Classic.
Available in: Enterprise, Performance, Unlimited, and Developer Editions
USER PERMISSIONS
To create or change custom fields:
•
Customize Application
Before you can add videos to the HTML editor in a Knowledge article, make sure that your browser security settings allow you to embed multimedia content. Some browser security settings can block
179
Extend Salesforce with Clicks, Not Code Customize Fields
<iframe>
elements. For example, if browser security is set to high in Internet Explorer 7,
<iframe>
content does not appear in the frame.
When the option to embed multimedia content is enabled during the setup of your application, users can cut and paste
<iframe>
HTML elements into the editor using one of two options:
1. Copy the
<iframe>
element from one of the approved video sites.
Approved sites include Dailymotion, Vimeo, or YouTube.
2. Paste the code into the HTML editor by clicking one of these buttons:
Option Description
Lets you paste the
<iframe>
element into a text box on the
Embed Multimedia Content dialog box. The frame and its contents are added to the editor window.
Lets you paste the
<iframe>
element directly into the HTML code.
3. Click Save.
SEE ALSO:
Adding Code Samples to Posts
You can paste code samples into your posts in Chatter Answers and Ideas.
When you enable Chatter Answers and Ideas, users can add code samples to their posts. Code can be copied from any text editor and pasted into the body of a post with the formatting preserved.
1. Copy the code sample from a text editor to your clipboard.
2.
In the editor, enter the text for your posts and click the button to add the code sample.
3. Paste the code sample into the
Add a code sample
text box and click OK.
The code sample appears in the body of the post with its formatting intact.
180
Extend Salesforce with Clicks, Not Code Customize Fields
Change the Custom Field Type
Note: If you encrypt a custom field using Shield Platform Encryption, you can’t change the field type.
1. From the management settings for the field’s object, go to Fields.
Note: For fields on Salesforce Knowledge article types, from Setup, enter
Knowledge
Article Types
in the
Quick Find
box, select Knowledge Article Types, and then select an article type.
2. Click Edit next to the custom field you want to change.
3. Click Change Field Type.
4. Select a new data type and click Next.
5. Enter a field label, name, and any other attributes, and then save your changes.
Notes on Changing Custom Field Types
EDITIONS
Available in: both Salesforce
Classic and Lightning
Experience
Available in: All Editions
Standard Objects are not available in Database.com
Salesforce Connect external objects are available in:
Developer Edition and for an extra cost in: Enterprise,
Performance, and
Unlimited Editions
SEE ALSO:
Find Object Management Settings
USER PERMISSIONS
To change custom fields:
•
Customize Application
Notes on Changing Custom Field Types
Consider the following before converting fields:
•
Only convert custom fields for which no data exists or you risk losing your data. Changing the data type of an existing custom field can cause data loss in the following situations:
–
Changing to or from type Date or Date/Time
–
Changing to Number from any other type
–
Changing to Percent from any other type
–
Changing to Currency from any other type
–
Changing from Checkbox to any other type
–
Changing from Picklist (Multi-Select) to any other type
–
Changing to Picklist (Multi-Select) from any other type
Currently defined picklist values are retained when you change a picklist to a multi-select picklist. If records contain values that are not in the picklist definition, those values are deleted from those records when the data type changes.
–
Changing from Auto Number to any other type
–
Changing to Auto Number from any type except Text
–
Changing from Text to Picklist
–
Changing from Text Area (Long) to any type except Email, Phone, Text, Text Area, or URL
•
If data is lost, any list view based on the custom field is deleted, and assignment and escalation rules may be affected.
•
You can’t change the data type of any custom field that is mapped for lead conversion.
•
If you change the data type of a custom field that is set as an external ID, choosing a data type other than text, number, or email causes the field to no longer act as an external ID.
181
Extend Salesforce with Clicks, Not Code Customize Fields
•
The option to change the data type of a custom field is not available for all data types. For example, existing custom fields cannot be converted into encrypted fields nor can encrypted fields be converted into another data type.
•
In Salesforce Knowledge article types, the file field type can't be converted into other data types.
•
You cannot change the data type of a custom field referenced by other items in Setup, like Visualforce pages, Apex code, Process
Builder, or flows.
•
Changing a custom field type may require changing many records at once. To process these changes efficiently, your request may be queued and you may receive an email notification when the process has completed.
•
Before changing a custom field’s type, make sure that it isn’t the target of a workflow field update or referenced in a field update formula that would be invalidated by the new type.
The following data types have additional restrictions when you convert them:
Data Type
Auto Number
Formula
Picklist
Relationships
Description
The data in any auto-number field remains unchanged if you convert it into a text field. Also, you can safely convert a text custom field into an auto-number field without losing your data. Converting an auto-number field into any other data type results in data loss.
Auto-number fields can contain a maximum of 30 characters. Before converting a text custom field into an auto-number field, change any records that contain more than 30 characters in that field.
Formula fields are special read-only fields that cannot be converted to any other data type. Likewise, you cannot convert any other field type into a formula field.
Changing your custom picklists into custom checkboxes is simple.
If you select Checkbox as the new data type, you can choose which picklist values to map to checked boxes and unchecked boxes.
You can change custom picklists into multi-select picklists without losing any data. Since your records only contain a single value of that picklist, that value is still selected but users can select more values.
•
You can convert relationship fields to nonrelationship fields and vice versa, but only on external objects.
•
If your organization has a large number of records, Salesforce displays a waiting page after you have requested to change a master-detail into a lookup relationship or a lookup into a master-detail relationship.
•
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.
•
A lookup cannot be converted to a master detail relationship if there are any existing records on the object that have a null value set for the lookup relationship.
•
If you are converting a master-detail relationship to a lookup for a custom object on the “detail” side, the organization-wide default for the object is automatically updated to Public
182
Extend Salesforce with Clicks, Not Code Customize Fields
Data Type
Text Area (Long)
Text Area (Rich)
Description
Read/Write. Similarly, converting a lookup to a master-detail-relationship changes the organization-wide default to Controlled by Parent
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.
You can only convert rich text area fields into long text area fields.
Any images are deleted the next time the long text area field is saved. After converting, markup is hidden in the long text area field but it is not removed from the record until you save the record.
That way, the markup can be restored if you change your mind.
SEE ALSO:
Define Default Field Values
Define a default value for a field. Use a formula to generate dynamic values, or constants for static values.
To define a default field value:
1. Begin by creating a custom field; see Create Custom Fields
on page 131. You can also define a
default value for an existing custom field; see Edit Custom Fields
on page 151.
2. Choose the type of field to create and click Next. For a list of the types available for default
values, see Default Field Values
on page 184.
3. Enter the attributes for the field.
4. Enter a default value or
define a formula to calculate the default value.
Note: You can define a formula for default values only where appropriate. For example, the default value options for a checkbox field are limited to the options available for those types of fields, such as Checked or Unchecked.
For picklists, a valid formula result is either a constant or the API name of an entry in the
Values list. The formula result has higher precedence than the default assigned in the
Values list. If the formula doesn’t generate a valid result, the default assigned in the Values list is entered in the field. If a default is not assigned to the Values list, no value is entered in the picklist field.
EDITIONS
Available in: both Salesforce
Classic and Lightning
Experience
Available in: Contact
Manager, Group,
Professional, Enterprise,
Performance, Unlimited, and Developer Editions
USER PERMISSIONS
To view default field values:
•
View Setup and
Configuration
To define or change default field values:
•
Customize Application
5. Click Next.
6. Set the field-level security to determine whether the field should be visible for specific profiles, and click Next.
7. Choose the page layouts that should display the field. The field is added as the last field in the first two-column section on the page layout. For user custom fields, the field is automatically added to the bottom of the user detail page.
8. Click Save to finish or Save & New to create more custom fields.
183
Extend Salesforce with Clicks, Not Code Customize Fields
Note:
You must specify a default value for required campaign member custom fields.
Don’t assign default values to fields that are both required and unique, because uniqueness errors can result.
Prepopulate field values with defaults to save your users time and improve consistency. Default field values make your users more productive by reducing the number of fields they need to fill in manually.
Useful Default Field Value Formulas
Default Field Value Considerations
Be aware of the behavior and rules when you assign default values to custom fields.
Default Field Values
Prepopulate field values with defaults to save your users time and improve consistency. Default field values make your users more productive by reducing the number of fields they need to fill in manually.
Default field values automatically insert the value of a custom field when a new record is created.
You can use a default value on a formula for some types of fields or exact values, such as Checked or Unchecked for checkbox fields.
After you have defined default values:
1. The user chooses to create a new record.
2. Default field value is executed.
3. Salesforce displays the edit page with the default field value prepopulated.
4. The user enters the fields for the new record.
5. The user saves the new record.
EDITIONS
Available in: both Salesforce
Classic and Lightning
Experience
Available in: Contact
Manager, Group,
Professional, Enterprise,
Performance, Unlimited, and Developer Editions
The user can change the field’s value but the initial default field value is only executed once, during record creation. For example, you can set the default field value on a custom lead field to seven days after the creation date to signify when to contact the lead again. You can change this value later, but you cannot automatically restore the value that was seven days after the creation date.
Set up default field values for the following types of custom fields:
•
Checkbox
•
Currency
•
Date
•
Date/Time
•
•
Number
•
Percent
•
Phone
•
Picklist
•
Text
•
Text Area
•
URL
184
Extend Salesforce with Clicks, Not Code Customize Fields
For a description of these types, see Custom Field Types
on page 137.
SEE ALSO:
Useful Default Field Value Formulas
Maximum Discount Rate
Your organization my apply different discount rates to opportunities based on the department of the person creating the opportunity. Use the following example to set a default value for a custom field called
Discount Rate
on opportunities.
EDITIONS
Available in: both Salesforce
Classic and Lightning
Experience
Available in: Contact
Manager, Group,
Professional, Enterprise,
Performance, Unlimited, and Developer Editions
USER PERMISSIONS
To view default field values:
•
View Setup and
Configuration
To define or change default field values:
•
Customize Application
CASE(User.Department, "IT", 0.25, "Field", 0.15, 0)
In this example, the formula inserts a discount rate of 25% on any opportunity created by a user in the “IT” department or 15% on any opportunity created by someone in the “Field” department. A zero is applied if the creator does not belong to either of these departments.
This is a custom percent field on opportunities that uses the standard user field
Department
.
Product Language
You may want to associate a product with its language so that your users know the type of documentation or adapter to include. Use the following default value formula to automatically set the language of a product based on the country of the user creating the product.
In this example, the default value is “Japanese” if the user's country is “Japan” and “English” if the user's country is “US.” If neither is true, the default value “unknown” is inserted into the
Product Language
field.
CASE($User.Country , "Japan", "Japanese", "US", "English","unknown")
Tax Rate
Use this default value formula to set the tax rate of an asset based on the user's city. Create a custom percent field with the following default value:
IF($User.City = "Napa", 0.0750,
IF($User.City = "Paso Robles", 0.0725,
185
Extend Salesforce with Clicks, Not Code Customize Fields
)
)
)
)
IF($User.City = "Sutter Creek", 0.0725,
IF($User.City = "Los Olivos", 0.0750,
IF($User.City = "Livermore", 0.0875, null
)
In this example, a tax rate of 8.75% is applied to an asset when the user's address is in the city of Livermore. When none of the cities listed apply, the
Tax Rate
field is empty. You can also use the
Tax Rate
field in formulas to automatically calculate taxable amounts and final sales prices.
SEE ALSO:
Default Field Value Considerations
Be aware of the behavior and rules when you assign default values to custom fields.
Default field values automatically insert the value of a custom field when a new record is created.
You can use a default value on a formula for some types of fields or exact values, such as Checked or Unchecked for checkbox fields. Review the following considerations before incorporating default field values in your organization.
EDITIONS
Available in: both Salesforce
Classic and Lightning
Experience
•
If a default value is based on the value of a merge field, Salesforce uses the value of the merge field at the time the default value is executed. If the value of the merge field changes later, the default value is not updated.
•
Users can change or remove the default field value on a record.
•
Don’t assign default values to fields that are both required and unique, because uniqueness errors can result.
•
If you make an activity custom field universally required, you must also provide a default value.
•
If an activity custom field is unique, you cannot provide a default value.
Available in: Contact
Manager, Group,
Professional, Enterprise,
Performance, Unlimited, and Developer Editions
•
Default field values are different from formula fields in the following ways: they are only executed once, at record creation; they are not read only; and the user can change the value but cannot restore the default field value.
•
Since the default value is inserted before users enter any values in the new record, you cannot use the fields on the current record to create a default field value. For example, you cannot create a default field value on a contact that uses the first initial and last name because those values are not available when you click New to create a contact record. However, you can use the record type because it is selected before the record edit page displays.
•
To apply a different default value for different record types, use the record type as a merge field in a CASE function within the default field value setup.
•
Fields that are not visible to the user due to field-level security are still available in the formula for a default field value.
•
Connect Offline and Salesforce for Outlook do not display default values. However, Salesforce inserts the default values when a user syncs unless the user entered a value.
•
Default field values are not available in the Self-Service portal.
•
Lead conversion, Web-to-Lead, and Web-to-Case do not execute default field values.
186
Extend Salesforce with Clicks, Not Code Customize Fields
Note: You can define a formula for default values only where appropriate. For example, the default value options for a checkbox field are limited to the options available for those types of fields, such as Checked or Unchecked.
For picklists, a valid formula result is either a constant or the API name of an entry in the Values list. The formula result has higher precedence than the default assigned in the Values list. If the formula doesn’t generate a valid result, the default assigned in the
Values list is entered in the field. If a default is not assigned to the Values list, no value is entered in the picklist field.
SEE ALSO:
Validation Rules
Improve the quality of your data using validation rules. Validation rules verify that the data a user enters in a record meets the standards you specify before the user can save the record. A validation rule can contain a formula or expression that evaluates the data in one or more fields and returns a value of “True” or “False”. Validation rules also include an error message to display to the user when the rule returns a value of “True” due to an invalid value.
After you have defined validation rules:
1. The user chooses to create a new record or edit an existing record.
2. The user clicks Save.
3. All validation rules are verified.
•
If all data is valid, the record is saved.
•
If any data is invalid, the associated error message displays without saving the record.
EDITIONS
Available in: both Salesforce
Classic and Lightning
Experience
Available in: Contact
Manager, Group,
Professional, Enterprise,
Performance, Unlimited,
Developer, and
Database.com Editions
4. The user makes the necessary changes and clicks Save again.
You can specify the error message to display when a record fails validation and where to display it. For example, your error message can be “The close date must occur after today's date.” You can choose to display it near a field or at the top of the page. Like all other error messages, validation rule errors display in red text and are preceded by the word “Error”.
Important: Validation rules apply to new and updated records for an object, even if the fields referenced in the validation rule are not included in a page layout or an API call. Validation rules don't apply if you create new records for an object with Quick
Create. If your organization has multiple page layouts for the object on which you create a validation rule, verify that the validation rule functions as intended on each layout. If your organization has any integrations that use this object, verify that the validation rule functions as intended for each integration.
Validation rules verify that the data a user enters in a record meets the standards you specify before the user can save the record. A validation rule can contain a formula or expression that evaluates the data in one or more fields and returns a value of “True” or
“False”. Validation rules also include an error message to display to the user when the rule returns a value of “True” due to an invalid value.
Tips for Writing Validation Rules
187
Extend Salesforce with Clicks, Not Code Customize Fields
Validation Rule Considerations
Validation rules verify that the data a user enters in a record meets the standards you specify before the user can save the record. A validation rule can contain a formula or expression that evaluates the data in one or more fields and returns a value of “True” or
“False”. Validation rules also include an error message to display to the user when the rule returns a value of “True” due to an invalid value. Review these considerations before implementing validation rules in your organization.
SEE ALSO:
Managing Validation Rules
Validation rules verify that the data a user enters in a record meets the standards you specify before the user can save the record. A validation rule can contain a formula or expression that evaluates the data in one or more fields and returns a value of “True” or “False”. Validation rules also include an error message to display to the user when the rule returns a value of “True” due to an invalid value.
From the validation rules page you can:
•
.
•
Click Edit next to a rule name to update the
•
Delete a validation rule.
•
Click a validation rule name to view more details or to
•
.
SEE ALSO:
EDITIONS
Available in: both Salesforce
Classic and Lightning
Experience
Available in: Contact
Manager, Group,
Professional, Enterprise,
Performance, Unlimited,
Developer, and
Database.com Editions
188
Extend Salesforce with Clicks, Not Code Customize Fields
Define Validation Rules
Validation rules verify that the data a user enters in a record meets the standards you specify before the user can save the record. A validation rule can contain a formula or expression that evaluates the data in one or more fields and returns a value of “True” or “False”. Validation rules also include an error message to display to the user when the rule returns a value of “True” due to an invalid value.
Before creating validation rules, review the
Validation Rule Considerations
.
1. From the management settings for the relevant object, go to Validation Rules.
2. In the Validation Rules related list, click New.
Note: The detail page of a custom activity field does not list associated validation rules.
To edit the validation rule for a custom activity field, select the validation rule from Setup by entering
Activities
in the
Quick Find
box, then selecting Activities and choose Task Validation Rules or Event Validation Rules.
3. Enter the
properties of your validation rule
.
4. To check your formula for errors, click Check Syntax.
EDITIONS
Available in: both Salesforce
Classic and Lightning
Experience
Available in: Contact
Manager, Group,
Professional, Enterprise,
Performance, Unlimited,
Developer, and
Database.com Editions
USER PERMISSIONS
To view field validation rules:
•
View Setup and
Configuration
To define or change field validation rules:
•
Customize Application
SEE ALSO:
Tips for Writing Validation Rules
Clone Validation Rules
1. From the management settings for the relevant object, go to Validation Rules.
2. In the Validation Rules related list, click the name of the validation rule.
3. Click Clone.
4.
Define the new rule based on the original rule.
5. Click Save to finish or Save & New to create additional validation rules.
Note:
The detail page of a custom activity field does not list associated validation rules. To edit the validation rule for a custom activity field, select the validation rule from Setup by entering
Activities
in the
Quick Find
box, then selecting Activities and choose
Task Validation Rules or Event Validation Rules.
SEE ALSO:
EDITIONS
Available in: both Salesforce
Classic and Lightning
Experience
Available in: Contact
Manager, Group,
Professional, Enterprise,
Performance, Unlimited,
Developer, and
Database.com Editions
USER PERMISSIONS
To view field validation rules:
•
View Setup and
Configuration
To define or change field validation rules:
•
Customize Application
189
Extend Salesforce with Clicks, Not Code Customize Fields
Activate Validation Rules
1. From the management settings for the relevant object, go to Validation Rules.
2. Click Edit next to the rule you want to activate.
3. To activate the rule, select Active, and save your changes.
4. To deactivate the rule, deselect Active, and save your changes.
Note: The detail page of a custom activity field does not list associated validation rules.
SEE ALSO:
Find Object Management Settings
EDITIONS
Available in: both Salesforce
Classic and Lightning
Experience
Available in: Contact
Manager, Group,
Professional, Enterprise,
Performance, Unlimited,
Developer, and
Database.com Editions
USER PERMISSIONS
To view field validation rules:
•
View Setup and
Configuration
To define or change field validation rules:
•
Customize Application
Validation Rules Fields
Field
Rule Name
Active
Description
Error Condition
Formula
Error Message
Error Location
Description
Unique identifier of up to 40 characters with no spaces or special characters such as extended characters.
Checkbox that indicates if the rule is enabled.
A 255-character or less description that distinguishes the validation rule from others. For internal purposes only.
The expression used to validate the field. See
and Formula Operators and Functions .
The message that displays to the user when a field fails the validation rule.
If your organization uses the Translation Workbench, you can translate the error message into the languages Salesforce supports.
See
Enable and Disable the Translation Workbench .
Determines where on the page to display the error. To display the error next to a field, choose
Field
and select the field. If the error location is a field, the validation rule is also listed on the detail page of that field. If the error location is set to a field that is later deleted, to a field that is read only, or to a field that isn’t visible on
EDITIONS
Available in: both Salesforce
Classic and Lightning
Experience
Available in: Contact
Manager, Group,
Professional, Enterprise,
Performance, Unlimited,
Developer, and
Database.com Editions
190
Extend Salesforce with Clicks, Not Code
Field
Customize Fields
Description
the page layout, Salesforce automatically changes the location to
Top of Page
.
Note:
Error messages can only be displayed at the top of the page in validation rules for case milestones and Ideas.
SEE ALSO:
Tips for Writing Validation Rules
•
Consider all the settings in your organization that can make a record fail validation, including assignment rules, field updates, field-level security, or fields hidden on a page layout.
•
Be careful not to create contradicting validation rules for the same field; otherwise, users won’t be able to save the record.
EDITIONS
Tip: A poorly designed validation rule can prevent users from saving valid data. Make sure you thoroughly test a validation rule before activating it. You can also use the debug log to monitor the details of your rule implementation.
•
When referencing related fields in a validation formula, make sure those objects are deployed.
•
Use the
RecordType.Id
merge field in your formula to apply different validations for different record types.
•
You don’t have to begin a validation rule formula with the IF function. Any Boolean error condition expression works. For example:
–
Correct:
CloseDate < TODAY()
–
Incorrect:
IF(CloseDate < TODAY(), TRUE, FALSE)
Available in: both Salesforce
Classic and Lightning
Experience
Available in: Contact
Manager, Group,
Professional, Enterprise,
Performance, Unlimited,
Developer, and
Database.com Editions
•
Keep in mind that when a validation rule contains the BEGINS or CONTAINS function, it processes blank fields as valid. For example, if you have a validation rule that tests whether the serial number of an asset begins with “3”, all assets with a blank serial number are considered valid.
•
When using a validation rule to ensure that a number field contains a specific value, use the ISBLANK function to include fields that don’t contain any value. For example, to validate that a custom field contains a value of ‘1’, use the following validation rule to display an error if the field is blank or any other number:
OR (ISBLANK (field__c), field__c<>1)
•
Avoid using the
IsClosed
or
IsWon
opportunity merge fields in validation formulas. Instead, use the ISPICKVAL function to determine if the
Stage
contains the appropriate value. For example, the following validation formula makes a custom
Project
Start Date
field required whenever the
Stage
is “Closed Won”:
AND(ISPICKVAL(StageName, "Closed Won"),
ISBLANK(Project_Start_Date__c))
•
Simplify your validation formulas by using checkbox fields, which don't require any operator because they return true or false. For example, the following validation formula checks to be sure an opportunity has opportunity products using the
HasOpportunityLineItem
merge field before users can save a change to it:
NOT(OR(ISNEW(),HasOpportunityLineItem))
191
Extend Salesforce with Clicks, Not Code Customize Fields
Tips for Writing Validation Rule Error Messages
•
Give instructions. An error message like “invalid entry” doesn’t tell the user what type of entry is valid. Write something more specific, such as “
Close Date
must be after today.”
•
Always include the field label. Users might not know what field is failing validation, especially if the error message appears at the top of the page.
Note: When defining validation rules, you can set the error location to
Top of Page
or
Field
. If the error location is set to a field that is later deleted, to a field that is read only, or to a field that isn’t visible on the page layout, Salesforce automatically changes the location to
Top of Page
.
•
If you have a multilingual organization, translate your error messages. You can translate error messages using the Translation
Workbench.
•
Assign corresponding numbers to validation rules and their error messages. This allows you to identify the source of the error.
SEE ALSO:
Validation Rule Considerations
Validation Rule Considerations
Validation rules verify that the data a user enters in a record meets the standards you specify before the user can save the record. A validation rule can contain a formula or expression that evaluates the data in one or more fields and returns a value of “True” or “False”. Validation rules also include an error message to display to the user when the rule returns a value of “True” due to an invalid value. Review these considerations before implementing validation rules in your organization.
EDITIONS
Available in: both Salesforce
Classic and Lightning
Experience
How Salesforce Processes Validation Rules
Salesforce processes rules in the following order:
1. Validation rules
2. Assignment rules
Available in: Contact
Manager, Group,
Professional, Enterprise,
Performance, Unlimited,
Developer, and
Database.com Editions
3. Auto-response rules
4. Workflow rules (with immediate actions)
5. Escalation rules
In addition,
•
When one validation rule fails, Salesforce continues to check other validation rules on that field or other fields n the page and displays all error messages at once.
•
If validation rules exist for activities and you create an activity during lead conversion, the lead converts but a task isn’t created.
•
Validation rules are only enforced during lead conversion if validation and triggers for lead conversion are enabled in your organization.
•
Campaign hierarchies ignore validation rules.
•
Salesforce runs validation rules before it creates records submitted via Web-to-Lead and Web-to-Case and then creates records that have valid values.
•
Validation rules continue to run on individual records if the owner is changed. If the Mass Transfer tool is used to change the ownership of multiple records, however, validation rules don’t run on those records.
192
Extend Salesforce with Clicks, Not Code Customize Fields
Validation Rule Field Restrictions
Validation rule formulas don’t or can’t refer to:
•
Compound fields, including addresses, first and last names, and dependent picklists and lookups
•
Campaign statistic fields, including statistics for individual campaigns and campaign hierarchies
•
Merge fields for auto-number or compound address fields such as
Mailing Address
Note: Merge fields for individual address fields, such as
Billing City
, are OK to use in validation rule formulas.
In relation to other fields and functions in Salesforce, validation rules behave as follows:
•
The detail page of a custom activity field doesn't list associated validation rules.
•
Workflow rules and some processes can invalidate previously valid fields. Invalidation occurs because updates to records based on workflow rules and also on process scheduled actions don’t trigger validation rules.
•
Process record updates on immediate actions do fire validation rules.
•
You can’t create validation rules for relationship group members.
•
You can use roll-up summary fields in validation rules because the fields don’t display on edit pages. Do not use roll-up summary fields as the error location.
Lookup Filters vs. Validation Rules
Validation rules and lookup filters achieve similar ends, but offer different advantages. Use a lookup filter if:
•
You want to improve user efficiency by limiting the number of available options in a lookup search dialog.
•
You want to improve user efficiency by automating filters on lookup search dialogs that your users manually set.
Use a validation rule if:
•
You're close to the maximum number of lookup filters allowed.
•
You must implement a complex business rule that requires you to use a formula. Formulas can reference fields that basic filter criteria can't reference, such as fields on the parent of the source object. Formulas can also use functions. For example, use
ISNEW
if the rule should only apply on record creation, or
ISCHANGED
if the rule should apply when a field changes.
SEE ALSO:
193
Extend Salesforce with Clicks, Not Code Customize Fields
Examples of Validation Rules
Review examples of validation rules for various types of apps that you can use and modify for your own purposes. Validation rules verify that the data a user enters in a record meets the standards you specify before the user can save the record.
Use the following samples for validation rules in Salesforce and Force.com AppExchange apps, including:
Sample Account Address Validation Rules
Sample Account Validation Rules
Sample Call Center Validation Rules
Sample Community Validation Rules
Sample Contact Validation Rules
Sample Cross Object Validation Rules
Sample Number Validation Rules
Sample Opportunity Management Validation Rules
Sample User, Role, and Profile Validation Rules
Miscellaneous Sample Validation Rules
EDITIONS
Available in: both Salesforce
Classic and Lightning
Experience
Available in: Contact
Manager, Group,
Professional, Enterprise,
Performance, Unlimited,
Developer, and
Database.com Editions
USER PERMISSIONS
To view field validation rules:
•
View Setup and
Configuration
To define or change field validation rules:
•
Customize Application
SEE ALSO:
Sample Account Address Validation Rules
EDITIONS
Available in: both Salesforce
Classic and Lightning
Experience
Available in: Contact
Manager, Group,
Professional, Enterprise,
Performance, Unlimited,
Developer, and
Database.com Editions
194
Extend Salesforce with Clicks, Not Code Customize Fields
Canadian Billing Postal Code
Field
Description:
Value
Validates that the account
Billing Zip/Postal Code
is in the correct format if
Billing Country
is Canada.
Formula:
AND(
OR(BillingCountry = "CAN", BillingCountry = "CA", BillingCountry
= "Canada"),
NOT(REGEX(BillingPostalCode,
"((?i)[ABCEGHJKLMNPRSTVXY]\\d[A-Z]?\\s?\\d[A-Z]\\d)?"))
)
Error Message:
Error Location:
Canadian postal code must be in A9A 9A9 format.
Billing Zip/Postal Code
Billing Zip Code Is in Billing State
Field
Description:
Value
Validates that the account
Billing Zip/Postal Code
is valid by looking up the first five characters of the value in a custom object called Zip_Code__c that contains a record for every valid zip code in the US. If the zip code is not found in the Zip_Code__c object, or the
Billing State
does not match the corresponding State_Code__c in the Zip_Code__c object, an error is displayed.
Formula:
VLOOKUP(
$ObjectType.Zip_Code__c.Fields.City__c ,
$ObjectType.Zip_Code__c.Fields.Name ,
LEFT(BillingPostalCode,5)) <> BillingCity
Error Message:
Error Location:
Billing Zip Code does not exist in specified Billing State.
Billing Zip/Postal Code
195
Extend Salesforce with Clicks, Not Code
US Billing Zip Code
Field
Description:
Formula:
Error Message:
Error Location:
Customize Fields
Value
Validates that the account
Billing Zip/Postal Code
is in 99999 or 99999-9999 format if
Billing Country
is USA or US.
AND(
OR(BillingCountry = "USA", BillingCountry = "US"),
NOT(REGEX(BillingPostalCode, "\\d{5}(-\\d{4})?"))
)
Note:
This example uses the
function; see
if you are not familiar with regular expressions.
Zip code must be in 99999 or 99999-9999 format.
Billing Zip/Postal Code
196
Extend Salesforce with Clicks, Not Code
Shipping Zip Code
Field
Description:
Formula:
Error Message:
Error Location:
Customize Fields
Value
Validates that the account
Shipping Zip/Postal Code
is in 99999 or 99999-9999 format if
Shipping Country
is USA or blank.
AND(
OR(ShippingCountry = "USA", ISBLANK(ShippingCountry)),
OR(
AND(LEN(ShippingPostalCode) <>5,
LEN(ShippingPostalCode) <> 10),
NOT(CONTAINS("0123456789",
LEFT( ShippingPostalCode, 1))),
NOT(CONTAINS("0123456789",
MID( ShippingPostalCode , 2, 1))),
NOT(CONTAINS("0123456789",
MID( ShippingPostalCode , 3, 1))),
NOT(CONTAINS("0123456789",
MID( ShippingPostalCode , 4, 1))),
NOT(CONTAINS("0123456789",
MID( ShippingPostalCode , 5, 1))),
AND(
LEN(ShippingPostalCode) = 10,
OR(
MID( ShippingPostalCode , 6, 1) <> "-",
NOT(CONTAINS("0123456789",
MID( ShippingPostalCode , 7, 1))),
NOT(CONTAINS("0123456789",
MID( ShippingPostalCode , 8, 1))),
)
)
)
)
NOT(CONTAINS("0123456789",
MID( ShippingPostalCode , 9, 1))),
NOT(CONTAINS("0123456789",
MID( ShippingPostalCode , 10, 1)))
Note:
This example interprets a blank country as US. To use this example with other countries, remove the clause that checks the length of the country field. Also, validation rule criteria are case sensitive, so this rule is only enforced when the country is blank or “USA” in all capital letters.
The rule is not enforced when the country is “usa.”
Tip: You can also validate zip codes using a regular expression; for an example of a formula using a regular expression, see
on page 294.
Zip code must be in 99999 or 99999-9999 format.
Shipping Zip/Postal Code
197
Extend Salesforce with Clicks, Not Code
Valid Billing State (US)
Field
Description:
Formula:
Error Message:
Error Location:
Customize Fields
Value
Validates that the account
Billing State/Province
is a valid two-character abbreviation if
Billing Country
is US, USA, or blank.
AND (
OR(BillingCountry = "US", BillingCountry="USA",
ISBLANK(BillingCountry)),
OR(
LEN(BillingState) < 2,
NOT(
CONTAINS("AL:AK:AZ:AR:CA:CO:CT:DE:DC:FL:GA:HI:ID:" &
"IL:IN:IA:KS:KY:LA:ME:MD:MA:MI:MN:MS:MO:MT:NE:NV:NH:" &
"NJ:NM:NY:NC:ND:OH:OK:OR:PA:RI:SC:SD:TN:TX:UT:VT:VA:" &
"WA:WV:WI:WY", BillingState)
)))
Note:
This example interprets a blank country as US. To use this example with other countries, remove the clause that checks the length of the country field. Also, validation rule criteria are case sensitive, so this rule is only enforced when the country is blank or “USA” in all capital letters. The rule is not enforced when the country is “usa.”
A valid two-letter state code is required.
Billing State/Province
Valid Billing Province (Canada)
Field
Description:
Value
Validates that the account
Billing State/Province
is a valid two-character abbreviation if
Billing
Country
is CA or CAN.
Formula:
AND (
OR(BillingCountry = "CA", BillingCountry="CAN"),
OR(
LEN(BillingState) < 2,
NOT(
CONTAINS("AB:BC:MB:NB:NL:NT:NS:NU:ON:PC:QC:SK:YT", BillingState)
)))
Error Message:
Error Location:
A valid two-letter province code is required.
Billing State/Province
198
Extend Salesforce with Clicks, Not Code Customize Fields
Valid Shipping State
Field
Description:
Value
Validates that the account
Shipping State/Province
is a valid two-character abbreviation if
Shipping Country
is US, USA, or blank.
Formula:
Error Message:
Error Location:
AND (
OR(ShippingCountry = "US", ShippingCountry="USA",
ISBLANK(ShippingCountry)),
OR(
LEN(ShippingState) < 2,
NOT(
CONTAINS("AL:AK:AZ:AR:CA:CO:CT:DE:DC:FL:GA:HI:ID:" &
"IL:IN:IA:KS:KY:LA:ME:MD:MA:MI:MN:MS:MO:MT:NE:NV:NH:" &
"NJ:NM:NY:NC:ND:OH:OK:OR:PA:RI:SC:SD:TN:TX:UT:VT:VA:" &
"WA:WV:WI:WY", ShippingState)
)))
Note:
This example interprets a blank country as US. To use this example with other countries, remove the clause that checks the length of the country field. Also, validation rule criteria are case sensitive, so this rule is only enforced when the country is blank or “USA” in all capital letters. The rule is not enforced when the country is “usa.”
A valid two-letter state abbreviation is required.
Shipping State/Province
Valid Shipping Province (Canada)
Field
Description:
Value
Validates that the account
Shipping State/Province
is a valid two-character abbreviation, if
Billing Country
is CA or CAN.
Formula:
AND (
OR(ShippingCountry = "CA", ShippingCountry="CAN"),
OR(
LEN(ShippingState) < 2,
NOT(
CONTAINS("AB:BC:MB:NB:NL:NT:NS:NU:ON:PC:QC:SK:YT", ShippingState)
)))
Error Message:
Error Location:
A valid two-letter province abbreviation is required.
Shipping State/Province
199
Extend Salesforce with Clicks, Not Code
Valid Billing Country
Field
Description:
Formula:
Value
Validates that the account
Billing Country
is a valid ISO 3166 two-letter code.
OR(
LEN(BillingCountry) = 1,
NOT(
CONTAINS(
"AF:AX:AL:DZ:AS:AD:AO:AI:AQ:AG:AR:AM:" &
"AW:AU:AZ:BS:BH:BD:BB:BY:BE:BZ:BJ:BM:BT:BO:" &
"BA:BW:BV:BR:IO:BN:BG:BF:BI:KH:CM:CA:CV:KY:" &
"CF:TD:CL:CN:CX:CC:CO:KM:CG:CD:CK:CR:CI:HR:" &
"CU:CY:CZ:DK:DJ:DM:DO:EC:EG:SV:GQ:ER:EE:ET:FK:" &
"FO:FJ:FI:FR:GF:PF:TF:GA:GM:GE:DE:GH:GI:GR:GL:" &
"GD:GP:GU:GT:GG:GN:GW:GY:HT:HM:VA:HN:HK:HU:" &
"IS:IN:ID:IR:IQ:IE:IM:IL:IT:JM:JP:JE:JO:KZ:KE:KI:" &
"KP:KR:KW:KG:LA:LV:LB:LS:LR:LY:LI:LT:LU:MO:MK:" &
"MG:MW:MY:MV:ML:MT:MH:MQ:MR:MU:YT:MX:FM:MD:MC:" &
"MC:MN:ME:MS:MA:MZ:MM:MA:NR:NP:NL:AN:NC:NZ:NI:" &
"NE:NG:NU:NF:MP:NO:OM:PK:PW:PS:PA:PG:PY:PE:PH:" &
"PN:PL:PT:PR:QA:RE:RO:RU:RW:SH:KN:LC:PM:VC:WS:" &
"SM:ST:SA:SN:RS:SC:SL:SG:SK:SI:SB:SO:ZA:GS:ES:" &
"LK:SD:SR:SJ:SZ:SE:CH:SY:TW:TJ:TZ:TH:TL:TG:TK:" &
"TO:TT:TN:TR:TM:TC:TV:UG:UA:AE:GB:US:UM:UY:UZ:" &
"VU:VE:VN:VG:VI:WF:EH:YE:ZM:ZW",
BillingCountry)))
Error Message:
Error Location:
A valid two-letter country code is required.
Billing Country
Customize Fields
Sample Account Validation Rules
Account Number Is Numeric
Field
Description:
Formula:
Value
Validates that the
Account Number
is numeric if not blank.
)
AND(
ISBLANK(AccountNumber),
NOT(ISNUMBER(AccountNumber))
Error Message:
Error Location:
Account Number is not numeric.
Account Number
EDITIONS
Available in: both Salesforce
Classic and Lightning
Experience
Available in: Contact
Manager, Group,
Professional, Enterprise,
Performance, Unlimited,
Developer, and
Database.com Editions
200
Extend Salesforce with Clicks, Not Code
Account Number Length
Field
Description:
Formula:
Error Message:
Error Location:
Customize Fields
Value
Validates that the
Account Number
is exactly seven digits (if it is not blank). The number seven is simply illustrative. You can change this to any number you like.
AND(
ISBLANK(AccountNumber),
LEN(AccountNumber) <> 7
)
Account Number must be seven digits.
Account Number
Annual Revenue Range
Field
Description:
Formula:
Error Message:
Error Location:
Value
Validates that the account
Annual Revenue
is not negative and does not exceed $100 billion. This limit is designed to catch typos.
OR(
AnnualRevenue < 0,
AnnualRevenue > 100000000000
)
Annual Revenue cannot exceed 100 billion.
Annual Revenue
Sample Call Center Validation Rules
EDITIONS
Available in: both Salesforce
Classic and Lightning
Experience
Available in: Contact
Manager, Group,
Professional, Enterprise,
Performance, Unlimited,
Developer, and
Database.com Editions
201
Extend Salesforce with Clicks, Not Code Customize Fields
Conditionally Require Description When Case Reason is “Other”
Field
Description:
Value
Validates that a custom field called
Other Reason
contains a value if a case has a
Case
Reason
of “Other.”
Formula:
AND(
ISPICKVAL( Reason, "Other" ),
ISBLANK(Other_Reason__c)
)
Error Message:
Error Location:
Description of Other Reason is required.
Other Reason
Prevent Open Cases from Being Reset to New
Field
Description:
Formula:
Value
If a case is already open, prevents the
Status
from being changed back to “New.”
AND(
ISCHANGED( Status ),
NOT(ISPICKVAL(PRIORVALUE( Status ), "New")),
ISPICKVAL( Status, "New")
)
Error Message:
Error Location:
Open case Status cannot be reset to New.
Status
Restrict Status of Re-Opened Cases
Field
Description:
Formula:
Value
Validates that the case
Status
is “Re-opened” when a closed case is opened again.
AND(
ISCHANGED( Status ),
OR(
ISPICKVAL(PRIORVALUE( Status ), "Closed"),
ISPICKVAL(PRIORVALUE( Status ),
"Closed in SSP")),
NOT( ISPICKVAL( Status, "Re-Opened"))
)
Error Message:
Error Location:
Closed case can only be changed to “Re-opened.”
Status
202
Extend Salesforce with Clicks, Not Code Customize Fields
Prevent Case Milestone Completion After Cases Are Closed
Field
Description:
Value
Validates that a milestone's
Completion Date
can't occur after the case's
Status
is
Closed.
Formula:
Case.IsClosed
= true
Error Message:
Error Location:
You can't complete a milestone after a case is closed.
Top of Page
Prevent Case Milestone Completion Before Case Creation Dates
Field
Description:
Value
Validates that the milestone's
Completion Date
has occurred after the case's
Date/Time Opened
.
Formula:
CompletionDate >= Case.CreatedDate
&& CompletionDate <=
Case.ClosedDate
Error Message:
Error Location:
The milestone Completion Date must occur after the date the case was created and before the case was closed.
Top of Page
Sample Community Validation Rules
Preventing Offensive Language in Questions
Field
Description:
Value
Prevents users from entering offensive language in the
Title
and
Description
fields when asking a question.
Formula:
OR(CONTAINS(Title, 'darn'), CONTAINS(Body,
'darn'))
Error Message:
Question title or description contains offensive language.
EDITIONS
Available in: both Salesforce
Classic and Lightning
Experience
Available in: Contact
Manager, Group,
Professional, Enterprise,
Performance, Unlimited,
Developer, and
Database.com Editions
203
Extend Salesforce with Clicks, Not Code
Preventing Offensive Language in Replies
Field
Description:
Formula:
Value
Prevents users from entering offensive language when replying to a question.
OR(CONTAINS(Body, 'darn'), CONTAINS(Body, 'dang'))
Error Message:
Reply contains offensive language.
Customize Fields
Preventing Offensive Language in Ideas
Field
Description:
Value
Prevents users from entering offensive language in the
Title
and
Description
fields when posting an idea.
Formula:
OR(CONTAINS(Title, 'darn'), CONTAINS(Body, 'darn'))
Error Message:
Idea title or description contains offensive language.
Preventing Offensive Language in Idea Comments
Field
Description:
Formula:
Value
Prevents users from entering offensive language when posting a comment.
OR(CONTAINS(CommentBody , 'darn'), CONTAINS(CommentBody,
'dang'))
Error Message:
Comment contains offensive language.
Sample Contact Validation Rules
EDITIONS
Available in: both Salesforce
Classic and Lightning
Experience
Available in: Contact
Manager, Group,
Professional, Enterprise,
Performance, Unlimited,
Developer, and
Database.com Editions
204
Extend Salesforce with Clicks, Not Code Customize Fields
Mailing Address Fields Are Required
Field
Description:
Value
Validates that the contact
Mailing Street
,
Mailing City
, and
Mailing
Country
are provided.
Formula:
OR(
ISBLANK( MailingStreet ),
ISBLANK( MailingCity ),
ISBLANK( MailingCountry )
)
Error Message:
Error Location:
Mailing Street, City, and Country are required.
Top of Page
Mailing Street Is Required
Field
Description:
Formula:
Error Message:
Error Location:
Value
Validates that the contact
Mailing Street
is provided.
ISBLANK( MailingStreet )
Mailing Street is required.
Mailing Street
205
Extend Salesforce with Clicks, Not Code
Mailing Zip Code
Field
Description:
Formula:
Error Message:
Error Location:
Customize Fields
Value
Validates that the contact
Mailing Zip/Postal Code
is in 99999 or 99999-9999 format if
Mailing Country
is USA or blank.
AND(
OR(MailingCountry = "USA", ISBLANK(MailingCountry)),
OR(
AND(LEN(MailingPostalCode) <>5,
LEN(MailingPostalCode) <> 10),
NOT(CONTAINS("0123456789",
LEFT( MailingPostalCode, 1))),
NOT(CONTAINS("0123456789",
MID( MailingPostalCode , 2, 1))),
NOT(CONTAINS("0123456789",
MID( MailingPostalCode , 3, 1))),
NOT(CONTAINS("0123456789",
MID( MailingPostalCode , 4, 1))),
NOT(CONTAINS("0123456789",
MID( MailingPostalCode , 5, 1))),
AND(
LEN(MailingPostalCode) = 10,
OR(
MID( MailingPostalCode , 6, 1) <> "-",
NOT(CONTAINS("0123456789",
MID( MailingPostalCode , 7, 1))),
NOT(CONTAINS("0123456789",
MID( MailingPostalCode , 8, 1))),
)
)
)
)
NOT(CONTAINS("0123456789",
MID( MailingPostalCode , 9, 1))),
NOT(CONTAINS("0123456789",
MID( MailingPostalCode , 10, 1)))
Note:
This example interprets a blank country as US. To use this example with other countries, remove the clause that checks the length of the country field. Also, validation rule criteria are case sensitive, so this rule is only enforced when the country is blank or “USA” in all capital letters.
The rule is not enforced when the country is “usa.”
Tip: You can also validate zip codes using a regular expression; for an example of a formula using a regular expression, see
on page 294.
Zip code must be in 99999 or 99999-9999 format.
Mailing Zip/Postal Code
206
Extend Salesforce with Clicks, Not Code Customize Fields
Phone Number Has International Format
Field
Description:
Value
Validates that the
Phone
number begins with a plus sign (+) for country code. Note that this validation rule conflicts with the ten-digit rule.
Formula:
LEFT(Phone, 1) <> "+"
Error Message:
Error Location:
Phone number must begin with + (country code).
Phone
US Phone Number Has Ten Digits
Field
Description:
Value
Validates that the
Phone
number is in (999) 999-9999 format. This works by using the REGEX function to check that the number has ten digits in the (999) 999-9999 format.
Formula:
NOT(REGEX(Phone, "\\D*?(\\d\\D*?){10}"))
Error Message:
Error Location:
US phone numbers should be in this format: (999) 999-9999.
Phone
Sample Cross Object Validation Rules
Discounts Must Be Within Range
This example consists of three validation rules on opportunity products. The examples below work together to help you manage discount amounts for products and require a custom percent field on opportunity products called
Line Discount
. The examples below also require you to use price books and customize the
Product Family
field to include the following values:
Software
,
Consulting
, and
Training
.
Software Discounts
Field
Description:
Value
Prevents users from saving software products with a discount over 10 percent.
Formula:
AND(Line_Discount__c > 0.10,
ISPICKVAL(Product2.Family,
"Software"))
EDITIONS
Available in: both Salesforce
Classic and Lightning
Experience
Available in: Contact
Manager, Group,
Professional, Enterprise,
Performance, Unlimited,
Developer, and
Database.com Editions
207
Extend Salesforce with Clicks, Not Code Customize Fields
Field
Error Message:
Error Location:
Consulting Discounts
Field
Description:
Formula:
Value
The discount must be 10% or less for software products.
Line Discount
Value
Prevents users from saving consulting products with a discount over 15 percent.
AND(Line_Discount__c > 0.15,
ISPICKVAL(Product2.Family, "Consulting"))
The discount must be 15% or less for consulting products.
Line Discount
Error Message:
Error Location:
Training Discounts
Field
Description:
Formula:
Value
Prevents users from saving training products with a discount over
20 percent.
AND(Line_Discount__c > 0.20,
ISPICKVAL(Product2.Family, "Training"))
The discount must be 20% or less for training products.
Line Discount
Error Message:
Error Location:
Prevent Changing Opportunity Products on Closed Opportunities
This example consists of two validation rules: one on opportunity products and another on opportunities.
Field
Description:
Value
Prevents users from editing opportunity products after an opportunity is closed. Create the following validation rule example on opportunity products.
Formula:
OR(ISPICKVAL(Opportunity.StageName, "Closed
Won"), ISPICKVAL(Opportunity.StageName,
"Closed Lost"))
Error Message:
Cannot change opportunity products for closed opportunities.
208
Extend Salesforce with Clicks, Not Code Customize Fields
Field
Error Location:
The following validation rule is on opportunities.
Field
Description:
Value
Top of Page
Formula:
Value
Prevents users from deleting opportunity products after an opportunity is closed. Create the following validation rule example on opportunities. It uses a custom roll-up summary field on opportunities that counts the number of opportunity products on an opportunity.
AND(OR(ISPICKVAL(StageName, "Closed Won"),
ISPICKVAL(StageName, "Closed Lost")),
Number_of_Line_Items__c <
PRIORVALUE(Number_of_Line_Items__c) )
Cannot delete opportunity products for closed opportunities.
Top of Page
Error Message:
Error Location:
Prevent Saving a Case When Account Does Not Have Support
Field
Description:
Value
Prevents users from saving a case for an account that does not have support. This example assumes you have a custom checkbox field on accounts called
Allowed Support
that tracks if the account has support.
Formula:
Account.Allowed_Support__c
= FALSE
Error Message:
Error Location:
Unable to create cases for this account because it is not signed up for support.
Top of Page
Prevent Saving a Case When Contact is No Longer with the Company
Field
Description:
Value
Prevents users from saving an open case associated with a contact that is no longer with the company. This example uses a custom checkbox field on contacts called
No Longer With
Company
.
209
Extend Salesforce with Clicks, Not Code Customize Fields
Field
Formula:
Error Message:
Error Location:
Value
AND(Contact.Not_Longer_With_Company__c,
NOT(IsClosed))
Unable to save this case because the related contact is no longer with the company. To continue, choose another contact.
Contact Name
Sample Date Validation Rules
Date Must Be a Weekday
Field
Description:
Value
Validates that the value of a custom date field is a weekday (not
Saturday or Sunday).
Formula:
CASE(MOD( My_Date__c - DATE(1900, 1, 7), 7),
0, 0,
6, 0,
1) = 0
Error Message:
Error Location:
Date must be a weekday.
My Date
EDITIONS
Available in: both Salesforce
Classic and Lightning
Experience
Available in: Contact
Manager, Group,
Professional, Enterprise,
Performance, Unlimited,
Developer, and
Database.com Editions
Date Must Be a Weekend Day
Field
Description:
Formula:
Value
Validates that the value of a custom date field is a Saturday or Sunday.
CASE( MOD( My_Date__c - DATE(1900, 1, 7), 7),
0, 1,
6, 1,
0) = 0
Error Message:
Error Location:
Date must be a weekend day.
My Date
210
Extend Salesforce with Clicks, Not Code Customize Fields
Date Must Be in the Current Month
Field
Description:
Formula:
Value
Validates that a custom date field contains a date within the current month and year.
OR (
YEAR( My_Date__c ) <> YEAR ( TODAY() ),
MONTH( My_Date__c ) <> MONTH ( TODAY() )
)
Error Message:
Error Location:
Date must be in the current month.
My Date
Date Must Be in the Current Year
Field
Description:
Formula:
Error Message:
Error Location:
Value
Validates that a custom date field contains a date within the current year.
YEAR( My_Date__c ) <> YEAR ( TODAY() )
Date must be in the current year.
My Date
Date Must Be the Last Day of the Month
Field
Description:
Value
Validates whether a custom field called
My Date
is the last day of the month. To do this, it determines the date of the first day of the next month and then subtracts 1 day. It includes special case logic for December.
Formula:
DAY(My_Date__c) <>
IF(Month(My_Date__c)=12, 31,
DAY(DATE(YEAR(My_Date__c),MONTH(My_Date__c)+1,1) - 1))
Error Message:
Error Location:
Date must be the last day of the month.
My Date
211
Extend Salesforce with Clicks, Not Code Customize Fields
Date Must Be Within One Year of Today
Field
Description:
Value
Validates whether a custom field called
Follow-Up Date
is within one year of today’s date. This example assumes a 365 day year. (It does not handle leap years.)
Formula:
Followup_Date__c - TODAY() > 365
Error Message:
Error Location:
Follow-Up Date must be within one year of today.
Follow-Up Date
Day of Month Cannot Be Greater Than 15
Field
Description:
Value
Validates that a custom field called
Begin Date
contains a date in the first 15 days of the specified month.
Formula:
DAY( Begin_Date__c ) > 15
Error Message:
Error Location:
Begin Date cannot be after the 15th day of month.
Begin Date
End Date Cannot Be Before Begin Date
Field
Description:
Value
Validates that a custom field called
End Date
does not come before another custom field called
Begin Date
.
Formula:
Begin_Date__c > End_Date__c
Error Message:
Error Location:
End Date cannot be before Begin Date.
Begin Date
212
Extend Salesforce with Clicks, Not Code Customize Fields
Expiration Date Cannot Be Before Close Date
Field
Description:
Value
Validates that a custom field called
Expiration Date
does not come before
Close
Date
.
Formula:
Expiration_Date__c < CloseDate
Error Message:
Error Location:
Expiration Date cannot be before Close Date.
Expiration Date
Sample Number Validation Rules
Time Cards Must Total 40 Hours
Field
Description:
Value
Ensures that users cannot save a time card record with more than
40 hours in a work week. This example requires five custom fields on your custom object, one for each day of work.
Formula:
Monday_Hours__c +
Tuesday_Hours__c +
Wednesday_Hours__c +
Thursday_Hours__c +
Friday_Hours__c > 40
Error Message:
Error Location:
Your total hours cannot exceed 40.
Top of Page
EDITIONS
Available in: both Salesforce
Classic and Lightning
Experience
Available in: Contact
Manager, Group,
Professional, Enterprise,
Performance, Unlimited,
Developer, and
Database.com Editions
Number Cannot Be Negative
Field
Description:
Formula:
Value
Validates that a custom field called
Hours Worked
is not a negative number.
Hours_Worked__c < 0
Error Message:
Error Location:
Hours Worked cannot be less than zero.
Hours Worked
213
Extend Salesforce with Clicks, Not Code
Number Must Be Even
Field
Description:
Formula:
Error Message:
Error Location:
Customize Fields
Value
Validates that a custom field called
Ark Passengers
is a non-negative even number.
OR(
Ark_Passengers__c < 0,
MOD( Ark_Passengers__c, 2) <> 0
)
Ark Passengers must be a positive even number.
Ark Passengers
Number Must Be Odd
Field
Description:
Formula:
Value
Validates that a custom field called
Socks Found
is a non-negative odd number.
OR(
Socks_Found__c < 0,
MOD( Socks_Found__c, 2) = 0
)
Socks Found must be an odd number.
Socks Found
Error Message:
Error Location:
Number Must Be a Multiple of Five
Field
Description:
Formula:
Value
Validates that a custom field called
Multiple of 5
is a multiple of five.
MOD( Multiple_of_5__c, 5) <> 0
Error Message:
Error Location:
Number must be a multiple of five.
Multiple of 5
214
Extend Salesforce with Clicks, Not Code
Number Must Be an Integer
Field
Description:
Formula:
Value
Validates that a custom field called
My Integer
is an integer.
FLOOR( My_Integer__c) <> My_Integer__c
Error Message:
Error Location:
This field must be an integer.
My Integer
Customize Fields
Number Must Be Between -50 and 50
Field
Description:
Formula:
Value
Validates that a custom field called
Volume
is between -50 and 50.
ABS( Volume__c) > 50
Error Message:
Error Location:
Volume must be between -50 and 50.
Volume
Number Range Validation
Field
Description:
Formula:
Error Message:
Error Location:
Value
Validates that the range between two custom fields,
Salary Min
and
Salary Max
, is no greater than $20,000.
(Salary_Max__c - Salary_Min__c) > 20000
Salary range must be within $20,000. Adjust the Salary Max or Salary Min values.
Salary Max
215
Extend Salesforce with Clicks, Not Code Customize Fields
Percentage Must Be Between Zero and 100
Field
Description:
Value
Validates that a custom field called
Mix Pct
is between 0 and 100%. Note that percent fields are expressed divided by 100 in formulas (100% is expressed as 1; 50% is expressed as 0.5).
Formula:
OR(
Mix_Pct__c > 1.0,
Mix_Pct__c < 0.0
)
Error Message:
Error Location:
Mix Pct must be between 0 and 100%.
Mix Pct
Sample Opportunity Management Validation Rules
Conditionally-Required Field Based on Opportunity Stage
Field
Description:
Value
Validates that a custom field called
Delivery Date
is provided if an opportunity has advanced to the Closed Won or
Negotiation/Review stage.
Formula:
AND (
OR (
ISPICKVAL(StageName, "Closed Won"),
ISPICKVAL(StageName,
"Negotiation/Review")),
ISBLANK(Delivery_Date__c)
)
Error Message:
Error Location:
Delivery Date is required for this stage.
Delivery Date
EDITIONS
Available in: both Salesforce
Classic and Lightning
Experience
Available in: Contact
Manager, Group,
Professional, Enterprise,
Performance, Unlimited,
Developer, and
Database.com Editions
216
Extend Salesforce with Clicks, Not Code Customize Fields
Close Date Cannot Be Prior to Current Month
Field
Description:
Value
Validates that the
Close Date
of an opportunity is not within a month prior to the current month. Note the use of ISNEW and ISCHANGED in this formula to ensure the condition is only checked when the opportunity is being created or the
Close Date
field is modified subsequently.
Formula:
AND(
OR (
ISNEW(),
ISCHANGED( CloseDate )),
CloseDate < DATE( YEAR(TODAY()), MONTH(TODAY()), 1) )
Error Message:
Error Location:
Close Date cannot be prior to current month.
Close Date
Close Date Must Be a Future Date
Field
Description:
Formula:
Value
Ensures that users do not change the
Close Date
of an opportunity to a day in the past.
SampleDate < TODAY()
Error Message:
Error Location:
Close Date cannot be a day in the past.
Close Date
Discounts on Opportunities
Field
Description:
Formula:
Error Message:
Error Location:
Value
Validates that a custom discount percent field is between 0 and 40%.
OR(Discount_Rate__c < 0, Discount_Rate__c > 0.40)
The Discount Rate must not exceed 40%.
Discount Rate
217
Extend Salesforce with Clicks, Not Code Customize Fields
High-Value Opportunity Must Be Approved Before Closed
Field
Description:
Value
Opportunities with amounts greater than $50,000 require that a custom checkbox field called
Approved
is checked in order to change the stage to Closed Won or Closed Lost. To automate this, set field-level security on the
Approved
checkbox so that it can only be checked via a custom approval process (Enterprise Edition, Unlimited Edition, or Performance Edition).
Formula:
AND(
OR(
ISPICKVAL(StageName,"Closed Won"),
ISPICKVAL(StageName,"Closed Lost")),
(Amount > 50000),
NOT(ISPICKVAL(Approval_Status__c ,"Approved")))
Error Message:
Error Location:
All high-value opportunities must be approved for closure. Click the Request Close button.
Top of Page
Opportunity Amount Cannot Exceed $10 Million
Field
Description:
Value
Validates that opportunity
Amount
is positive and no more than $10 million. This limit is designed to catch typos.
Formula:
OR(
Amount < 0,
Amount > 10000000
)
Error Message:
Error Location:
Amount cannot exceed $10 million.
Amount
Opportunity Check for Products
Field
Description:
Value
Validates that an opportunity has at least one opportunity product before users can save a change to an opportunity.
Formula:
NOT(OR(ISNEW(),HasOpportunityLineItem))
Error Message:
Error Location:
You must add products to this opportunity before saving.
Top of Page
218
Extend Salesforce with Clicks, Not Code Customize Fields
Opportunity Must Have Products if Beyond “Needs Analysis” Stage
Field
Description:
Value
Validates that an opportunity has opportunity products before the
Stage
can move beyond
Needs Analysis.
Formula:
AND (
CASE( StageName,
"Value Proposition", 1,
"Id. Decision Makers", 1,
"Perception Analysis", 1,
"Proposal/Price Quote", 1,
"Negotiation/Review", 1,
"Closed Won", 1,
0) = 1,
NOT(HasOpportunityLineItem)
)
Error Message:
Error Location:
Opportunity products are required to advance beyond the Needs Analysis stage.
Top of Page
Opportunity Name Format
Field
Description:
Formula:
Error Message:
Error Location:
Value
Validates that an opportunity contains a hyphen as a way of enforcing an “[Account] - [Amount]” opportunity naming convention.
FIND( " - ", Name ) = 0
Opportunity Name should use “[Account] - [Amount]” format.
Opportunity Name
219
Extend Salesforce with Clicks, Not Code Customize Fields
Prevent Sales Reps from Moving Opportunity Stage Backwards
Field
Description:
Value
Prevent sales reps from changing opportunity
Stage
“backwards” to specific values, once they have accepted the opportunity via a custom approval process. The approval process sets the custom
Accepted Flag
checkbox to True.
Formula:
AND(
Accepted_Flag__c,
)
OR ( ISPICKVAL( StageName, "Stage 1"), ISPICKVAL( StageName,
"Stage 2"))
Error Message:
Error Location:
Invalid stage for accepted opportunity.
Stage
Probability Must Be 100% for Won Opportunities
Field
Description:
Value
Validates that the probability of a won opportunity is properly set to 100%. This is useful for data cleanliness and reporting purposes.
Formula:
AND (
ISPICKVAL( StageName, "Closed Won"),
Probability <> 1)
Error Message:
Error Location:
Probability must be 100% for won opportunities.
Probability
Probability Must Be Zero for Lost Opportunities
Field
Description:
Value
Validates that the probability of a lost opportunity is properly set to zero. This is useful for data cleanliness and reporting purposes.
Formula:
AND (
ISPICKVAL( StageName, "Closed Lost"),
Probability <> 0)
Error Message:
Error Location:
Probability must be 0% for lost opportunities.
Probability
220
Extend Salesforce with Clicks, Not Code
Project Start Date
Field
Description:
Formula:
Error Message:
Error Location:
Customize Fields
Value
Validates that a field is conditionally required based on the values of other fields. Use this validation formula to ensure that users include a
Project Start Date
for an opportunity that is closed/won.
AND(ISPICKVAL(StageName, "Closed Won"),
ISNULL(Project_Start_Date__c))
Project start date is required for won opportunities.
Project Start Date
Sample Quote Validation Rules
Display Error if Quote Line Item Discount Exceeds 40%
Field
Description:
Formula:
Value
Shows an error if a quote line item's discount exceeds 40%.
Discount > .40
Error Message:
Error Location:
The discount on this quote line item cannot exceed 40%.
Discount
on quote
EDITIONS
Available in: both Salesforce
Classic and Lightning
Experience
Available in: Contact
Manager, Group,
Professional, Enterprise,
Performance, Unlimited,
Developer, and
Database.com Editions
Sample User, Role, and Profile Validation Rules
EDITIONS
Available in: both Salesforce
Classic and Lightning
Experience
Available in: Contact
Manager, Group,
Professional, Enterprise,
Performance, Unlimited,
Developer, and
Database.com Editions
221
Extend Salesforce with Clicks, Not Code Customize Fields
Discount Percent Does Not Exceed Role-Based Limit
Field
Description:
Value
Validates that a custom field on opportunities called
Discount Percent
does not exceed a maximum value that varies depending on the user’s role. The default maximum is 15%.
Formula:
Discount_Percent__c >
VLOOKUP($ObjectType.Role_Limits__c.Fields.Limit__c,
$ObjectType.Role_Limits__c.Fields.Name,
$UserRole.Name)
Error Message:
Error Location:
Discount (%) exceeds limit allowed for your role.
Discount Percent
Expense Amount Does Not Exceed User's Max Allowed Expense
Field
Description:
Value
Validates a custom field called
Expense Amount
against a custom user field called
Max
Allowed Expense
.
Formula:
Expense_Amount__c > $User.Max_Allowed_Expense__c
Error Message:
Error Location:
Amount cannot exceed your maximum allowed expense.
Expense Amount
Only Record Owner Can Change Field
Field
Description:
Value
Ensures that only the record owner can make changes to a custom field called
Personal
Goal
.
Formula:
AND(
ISCHANGED( Personal_Goal__c ),
Owner <> $User.Id
)
Error Message:
Error Location:
Only record owner can change Personal Goal.
Personal Goal
222
Extend Salesforce with Clicks, Not Code Customize Fields
Only Record Owner or Administrator Can Change Field
Field
Description:
Value
Ensures that a user can make changes to a custom field called
Personal Goal
only if the user is the record owner or has a custom profile of “Custom: System Admin.”
Formula:
Error Message:
Error Location:
AND( ISCHANGED( Personal_Goal__c ), Owner <> $User.Id,
$Profile.Name <>
"Custom: System Admin" )
Note: $Profile merge fields are only available in Enterprise, Unlimited, Performance, and Developer Editions.
Only record owner or administrator can change Personal Goal.
Personal Goal
Opportunity Close Date Can Only Be Back-Dated by Administrator
Field
Description:
Value
Validates that the
Close Date
of an opportunity does not fall prior to the current month, except for users who have a custom profile called “Custom: System Admin.”
Formula:
Error Message:
Error Location:
AND(
OR (
ISNEW(),
ISCHANGED( CloseDate )),
CloseDate < DATE( YEAR(TODAY()), MONTH(TODAY()), 1),
$Profile.Name <> "Custom: System Admin"
)
Note: $Profile merge fields are only available in Enterprise, Unlimited, Performance, and Developer Editions.
Close Date cannot be prior to current month.
Close Date
223
Extend Salesforce with Clicks, Not Code Customize Fields
Miscellaneous Sample Validation Rules
Allow Number to Be Increased but Not Decreased
Field
Description:
Value
Allows a custom field called
Commit Amount
to be increased but not decreased after initial creation. This rule uses the
PRIORVALUE() function to compare the updated value of the field to its value prior to update.
Formula:
PRIORVALUE(Commit_Amount__c) >
Commit_Amount__c
Error Message:
Error Location:
Commit Amount cannot be decreased.
Commit Amount
EDITIONS
Available in: both Salesforce
Classic and Lightning
Experience
Available in: Contact
Manager, Group,
Professional, Enterprise,
Performance, Unlimited,
Developer, and
Database.com Editions
California Driver's License
Field
Description:
Formula:
Error Message:
Error Location:
Value
Ensures that a custom field called
Drivers License
is in the correct A9999999 format when the
Mailing State
is “CA”.
AND(
MailingState = "CA",
NOT(REGEX(Drivers_License__c, "([A-Z]\\d{7})?"))
)
Invalid California driver's license format.
Drivers License
224
Extend Salesforce with Clicks, Not Code Customize Fields
Force Users to Check “I Accept Terms” to Enter Certain Values
Field
Description:
Value
Uses a checkbox labeled “I accept terms” to force the user to select a checkbox in order to enter a value called
Number of Days
that exceeds their Paid Time Off (PTO) balance available.
Formula:
AND(
NOT( I_accept_terms__c ),
Number_of_Days__c > $User.PTO_Balance__c
)
Error Message:
Error Location:
Request will cause a negative PTO balance. You must accept Negative PTO Balance terms.
I accept terms
Prohibit Changes to a Field After It Has Been Saved
Field
Description:
Value
Prevents users from changing a custom field called
Guaranteed Rate
after it has been saved initially.
Formula:
AND(
NOT( ISNEW() ),
ISCHANGED( Guaranteed_Rate__c )
)
Error Message:
Error Location:
Guaranteed Rate cannot be changed.
Guaranteed Rate
225
Extend Salesforce with Clicks, Not Code Customize Fields
Social Security Number Format
Field
Description:
Value
Validates that a custom text field called
SSN
is formatted in 999-99-9999 number format (if it is not blank). The pattern specifies:
•
Three single digits (0-9):\\d{3}
•
A dash
•
Two single digits (0-9):\\d{2}
•
A dash
•
Four single digits (0-9):\\d{4}
Formula:
NOT(
OR(
ISBLANK(Social_Security_Number__c),
REGEX( Social_Security_Number__c , "[0-9]{3}-[0-9]{2}-[0-9]{4}")
)
)
Error Message:
Error Location:
SSN must be in this format: 999-99-9999.
SSN
Valid Currency
Field
Description:
Formula:
Error Message:
Error Location:
Value
Validates selected currency against an explicit subset of active currencies in your organization using the
Currency
picklist. Use this example if you only allow some of the active currencies in your organization to be applied to certain types of records.
CASE(CurrencyIsoCode,
"USD", 1,
"EUR", 1,
"GBP", 1,
"JPY", 1,
0) = 0
Currency must be USD, EUR, GBP, or JPY.
Currency
226
Extend Salesforce with Clicks, Not Code
Valid Credit Card Number
Field
Description:
Formula:
Error Message:
Error Location:
Customize Fields
Value
Validates that a custom text field called
Credit_Card_Number
is formatted in
9999-9999-9999-9999 or 9999999999999999 number format when it is not blank. The pattern specifies:
•
Four digits (0-9) followed by a dash: \\d{4}-
•
The aforementioned pattern is repeated three times by wrapping it in () {3}
•
Four digits (0-9)
•
The OR character (|) allows an alternative pattern of 16 digits of zero through nine with no dashes: \\d{16}
NOT( REGEX( Credit_Card_Number__c ,
"(((\\d{4}-){3}\\d{4})|\\d{16})?"))
Credit Card Number must be in this format: 9999-9999-9999-9999 or 9999999999999999.
Credit Card Number
Valid IP Address
Field
Description:
Formula:
Error Message:
Error Location:
Value
Ensures that a custom field called
IP Address
is in the correct format, four 3-digit numbers
(0-255) separated by periods.
NOT(
REGEX( IP_Address__c,
"^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.)
{3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$" ))
Error: IP Address must be in form 999.999.999.999 where each part is between 0 and 255.
IP Address
227
Extend Salesforce with Clicks, Not Code
Website Extension
Field
Description:
Formula:
Error Message:
Error Location:
Customize Fields
Value
Validates a custom field called
Web Site
to ensure its last four characters are in an explicit set of valid website extensions.
AND(
RIGHT( Web_Site__c, 4) <> ".COM",
RIGHT( Web_Site__c, 4) <> ".com",
RIGHT( Web_Site__c, 4) <> ".ORG",
RIGHT( Web_Site__c, 4) <> ".org",
RIGHT( Web_Site__c, 4) <> ".NET",
RIGHT( Web_Site__c, 4) <> ".net",
RIGHT( Web_Site__c, 6) <> ".CO.UK",
RIGHT( Web_Site__c, 6) <> ".co.uk"
)
Web Site must have an extension of
.com
,
.org
,
.net
, or
.co.uk
.
Web Site
Require Field Input to Ensure Data Quality
Improve the quality of data that users enter in Salesforce by creating universally required fields.
A universally required field is a custom field. It must have a value whenever a record is saved within
Salesforce, the Force.com API, Connect Offline, Salesforce for Outlook, the Self-Service portal, or automated processes such as Web-to-Lead and Web-to-Case. Making a field required on a page layout or through field-level security ensures that users must enter a value. Making a field required universally gives you a higher level of data quality beyond the presentation level of page layouts.
You can make the following types of custom fields universally required:
•
Currency
•
Date
•
Date/Time
•
•
Master-Detail Relationship (always required)
•
Number
•
Percent
•
Phone
•
Picklist
•
Text
•
Text Area
•
URL
EDITIONS
Available in: both Salesforce
Classic and Lightning
Experience
.
Available in: Contact
Manager, Group,
Professional, Enterprise,
Performance, Unlimited,
Developer, and
Database.com Editions
Connect Offline,
Salesforce for Outlook, the
Self-Service portal,
Web-to-Lead, and
Web-to-Case are not available in Database.com
To make a custom field universally required, select the Required checkbox when defining the custom field.
228
Extend Salesforce with Clicks, Not Code Customize Fields
Note:
You must specify a default value for required campaign member custom fields.
If you make a user field universally required, you must specify a default value for that field.
Relationship group members do not support universally required fields.
Considerations for Universally Required Fields
Considerations for Universally Required Fields
A universally required field is a custom field. It must have a value whenever a record is saved within
Salesforce, the Force.com API, Connect Offline, Salesforce for Outlook, the Self-Service portal, or automated processes such as Web-to-Lead and Web-to-Case. Review the following considerations before making your custom fields universally required.
EDITIONS
Available in: both Salesforce
Classic and Lightning
Experience
•
Standard fields cannot be universally required.
•
Universally required fields are required across all record types.
•
•
Edit pages always display universally required fields, regardless of field-level security.
When designing your page layouts, universally required fields:
–
Cannot be removed from a page layout
–
Are automatically added to the end of the first section of a page layout if not already on it
–
–
–
Cannot be read only or optional
Display in bold, indicating they are always visible
Are disabled on the field properties page because you cannot remove the required setting
•
Universally required fields are only enforced during lead conversion if validation and triggers for lead conversion are enabled in your organization.
•
Quick Create does not enforce universally required fields.
•
If you make an activity custom field universally required, you must also provide a default value.
Available in: Contact
Manager, Group,
Professional, Enterprise,
Performance, Unlimited,
Developer, and
Database.com Editions
Standard Objects, Page
Layouts, Connect Offline,
Salesforce for Outlook, the
Self-Service portal,
Web-to-Lead, and
Web-to-Cases are not available in Database.com
•
You must include universally required fields in your import files or the import will fail.
•
Don’t assign default values to fields that are both required and unique, because uniqueness errors can result.
•
You cannot make a field universally required if it is used by a field update that sets the field to a blank value.
•
Required fields may be blank on records that existed before making the field required. When a user updates a record with a blank required field, the user must enter a value in the required field before saving the record.
•
Web-to-Lead and Web-to-Case request data is not validated by Salesforce. Invalid data isn’t saved when requests are submitted. For example, if your custom field is a currency field and a user enters alphabetic characters such as “Abc” instead of numbers, the request is still submitted but with no value saved in the custom currency field.
SEE ALSO:
Require Field Input to Ensure Data Quality
229
Extend Salesforce with Clicks, Not Code Customize Fields
About Field Sets
A field set is a grouping of fields. For example, you could have a field set that contains fields describing a user's first name, middle name, last name, and business title. When a field set is added to a
Visualforce page, developers can loop over its fields and render them. If the page is added to a managed package, administrators can add, remove, or reorder fields in a field set to modify the fields presented on the Visualforce page without modifying any code. The same Visualforce page can present different sets of information, depending on which fields a subscriber prefers to keep.
As an administrator, you can create or edit field sets for your organization, or
. Field sets are available on all standard objects that support custom fields
, and any organization that supports creating Visualforce pages.
Fields added to a field set can be in one of two categories:
EDITIONS
Available in: Salesforce
Classic
Available in: Group,
Professional, Enterprise,
Performance, Unlimited, and Developer Editions
•
If a field is marked as
Available for the Field Set
, it exists in the field set, but the developer hasn’t presented it on the packaged Visualforce page. Administrators can display the field after the field set is deployed by moving it from the
Available column to the
In the Field Set
column.
•
If a field is marked as
In the Field Set
, the developer has rendered the field on the packaged Visualforce page by default.
Administrators can remove the field from the page after the field set is deployed by removing it from the
In the Field Set column.
Creating and Editing Field Sets
SEE ALSO:
Developer's Guide: Visualforce Developer's Guide
ISVforce Guide
Creating and Editing Field Sets
Salesforce has a drag-and-drop WYSIWYG tool for creating and editing field sets The enhanced field sets editor is enabled by default, and provides all of the functionality of the original editor, as well as additional functionality and an easier-to-use WYSIWYG interface.
1. From the management settings for the appropriate object, go to Field Sets, and then click New.
2. Enter a Field Set Label. This is the name presented to subscribers who install the field through a managed package.
3. Optionally, enter a name for your field set. This is used by your Visualforce page to reference the field set.
4. In the Where is this used? area, provide a brief description of which Visualforce pages use the field set, and for what purpose. This information helps a subscriber understand where and how an installed field set is being used, so that they can populate it with their own fields.
5. Save your changes.
EDITIONS
Available in: Salesforce
Classic
Available in: Contact
Manager, Group,
Professional, Enterprise,
Performance, Unlimited, and Developer Editions
6. To add fields to the field set, drag the fields from the object palette and drop them into the
Available for the Field
Set
or the
In the Field Set
container. The fields in the
Available for the Field Set
container are not initially visible on the Visualforce page. The fields in the
In the Field Set
container are visible by default.
230
Extend Salesforce with Clicks, Not Code Customize Fields
Note: In the field set, you can span to fields that reference multiple objects. When you span a field into a field set that references multiple objects, the only field you can span to is the
Name
object.
You can drag and drop a field from one container to the other. The vertical order of the
In the Field Set
list indicates the order of how the fields render on Visualforce pages.
7. To remove a field from the field set, drag the element back to the object palette, or click the icon next to the element.
8. To make a field required, double click the element or click the wrench icon ( ) next to it and select the
Required
checkbox.
Note: Indicates the field is required and must have a value to save the record.
9. Save your changes.
Important: The total number of cross object spans within the
In the Field Set
container can't exceed 25.
After a field set is deployed in your organization, you can always mark fields that are in the
Available for the Field Set list as
In the Field Set
, or vice versa. To do so:
1. Find the field set that you want to edit. From Setup enter
Installed Packages
in the
Quick Find
box, select Installed
Packages, click an installed package, and then click the field set you want to edit. Alternatively, if you know which object contains the field set you want to edit, go to the object detail page and click Edit in the field set related list.
2. If you didn't create the field set initially, you'll only be able to edit the fields within the field set. To move fields between containers, drag and drop a field from one container to the other. To change the order of a rendered field, drag a field up or down the list and drop the field in the order you want it to appear.
3. Save your changes.
SEE ALSO:
Field Sets Required Bit
You can define a field as required when you create or edit field sets. You may want to define a field as required to ensure a user enters the necessary information on a field. The required field is only available in the
In the Field Set
container. If you define a field as required in the
In the Field Set
container, and remove the field from the
In the Field Set
, the required attribute is removed.
Note: If you remove fields that were made required by an installed managed package from the
In the Field Set
container, the required attribute isn’t removed from those fields.
To define a field as required in a field set, see Creating and Editing Field Sets
on page 230
SEE ALSO:
EDITIONS
Available in: Salesforce
Classic
Available in: Group,
Professional, Enterprise,
Performance, Unlimited, and Developer Editions
231
Extend Salesforce with Clicks, Not Code Customize Fields
Roll-Up Summary Field
A roll-up summary field calculates values from related records, such as those in a related list. 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. The detail record must be related to the master through a master-detail relationship.
For example, you want to display the sum of invoice amounts for all related invoice custom object records in an account’s Invoices related list. You can display this total in a custom account field called Total Invoice Amount.
You can perform different types of calculations with a roll-up summary field. You can count the number of detail records related to a master record. Or, you can calculate the sum, minimum value, or maximum value of a field in the detail records.
Before you begin creating roll-up summary fields for your organization, review the implementation tips and best practices.
EDITIONS
Available in: both Salesforce
Classic and Lightning
Experience
Available in: Contact
Manager, Group,
Professional, Enterprise,
Performance, Unlimited,
Developer, and
Database.com Editions
Implementation Tips
Administration
•
Create roll-up summary fields on:
–
Any custom object that is on the master side of a master-detail relationship
–
Any standard object that is on the master side of a master-detail relationship with a custom object
–
Opportunities using the values of opportunity products related to the opportunity
–
Accounts using the values of related opportunities
–
Campaigns using campaign member status or the values of campaign member custom fields
Note: Campaign member custom formula fields that reference fields derived from leads or contacts are not supported.
•
The types of fields you can calculate in a roll-up summary field depend on the type of calculation. For example,
–
Number, currency, and percent fields are available when you select
SUM
as the roll-up type.
–
Number, currency, percent, date, and date/time fields are available when you select
MIN
or
MAX
as the roll-up type.
•
Sometimes you can’t change the field type of a field that you reference in a roll-up summary field.
•
Make sure that the filter for your roll-up summary doesn't encounter a formula field that results in “#Error!”. If one of your filter criteria uses a formula field that results in an error, no matches are returned for that filter criterion. For example, your roll-up summary filter is “Formula Field equals 10”. Two records contain errors, and one contains the value “10” in that field. In this case, your summary includes only the record with the value “10.”
•
When you delete a child record on a roll-up Summary field, Salesforce doesn’t recalculate the value of the field. Select the
Force a mass recalculation on this field
option on the edit page of the roll-up summary field to manually recalculate the value.
•
You can’t use long text area, multi-select picklist,
Description
fields, system fields like
Last Activity
, cross-object formula fields, and lookup fields in the field column of roll-up summary filters.
•
Auto number fields are not available as the field to aggregate in a roll-up summary field.
•
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.
•
Roll-up summary fields are not available for mapping lead fields of converted leads.
Management
232
Extend Salesforce with Clicks, Not Code Customize Fields
•
If a roll-up summary field doesn’t contain cross-object field references or functions that derive values on the fly, such as NOW or
TODAY, it can calculate the values of formula fields.
Note: The value of a formula field can result in “#Error!”, which affects the summarized total. If your roll-up summary type is
COUNT, records are included regardless of whether they contain a formula field with an error. However, when the
Field to Aggregate
is a formula field that results in “#Error!”, calculations of type MIN, MAX, and SUM exclude those formula values.
•
Changes to the value of a roll-up summary field can trigger assignment rules to run. If a roll-up summary field is part of the criteria in an assignment rule, the field’s new value is used to evaluate whether to reassign the record.
•
A roll-up summary field can trigger workflow rules and field validations. However, workflow rules and field validations do not fire when the following changes cause a mass recalculation of roll-up summary values:
–
Changing the roll-up summary definition (such as the object, function, or field being aggregated)
–
Changing the expression of a formula field referenced in a roll-up summary field
–
Replacing picklist values for picklist fields referenced in the roll-up summary filter
–
Changing picklist record type definitions
–
Changing currency conversion rates
–
Changing price book entries
•
Calculating roll-up summary field values can take up to 30 minutes, depending on the number of records affected and other factors.
•
You aren’t prevented from creating roll-up summary fields that can result in invalid values, such as February 29 in a non-leap year.
If a roll-up summary field results in an invalid value, the value is not recalculated. The field continues to display with an invalid roll-up summary icon ( ) until you change the values being summarized.
•
If your organization uses multiple currencies, the currency of the master record determines the currency of the roll-up summary field. For example, if the master and detail records are in different currencies, the detail record value is converted into the currency of the master record.
•
Changing a conversion rate triggers roll-up summary fields to recalculate. If you’re using multiple currencies, we recommend changing the conversion rate from Manage Currencies in Setup, and not from the API. If you change the rate from the API, related jobs that are less than 24 hours old can interfere with your change. For details, see Edit Conversion Rates.
•
If your organization has advanced currency management enabled, currency roll-up summary fields are invalid if they are on accounts and summarizing opportunity values, or on opportunities and summarizing custom object values.
•
Salesforce prevents users from saving a record if it invalidates a related record. For example, a master record has a validation rule that requires the roll-up summary field value to be greater than 100. If the user’s change to a related child record would put the value over 100, the user can’t save the record.
•
If a lookup field references a record that has been deleted, Salesforce clears the value of the lookup field by default. Alternatively, you can choose to prevent records from being deleted if they’re in a lookup relationship.
To be used in a roll-up summary field with a
Roll-Up Type
of
COUNT
or
SUM
, the lookup field must have the
What to do if the lookup record is deleted?
option set to
Don’t allow deletion of the lookup record that’s part of a lookup relationship
. If the option
Clear the value of this field. You can’t choose this option if you make the field required
is selected, you can’t create a
COUNT
or
SUM
roll-up summary field that pulls data from your lookup field.
Best Practices
•
Apply field-level security to your roll-up summary fields if they calculate values that you do not want visible to users. Fields that your users cannot see due to field-level security settings on the detail record are still calculated in a roll-up summary field.
233
Extend Salesforce with Clicks, Not Code Customize Fields
•
If you have validation rules, consider how they affect roll-up summary fields. The value in a roll-up summary field changes when the values in the detail records change. So, validation errors can display when saving either the detail or master record.
•
Because roll-up summary fields are not displayed on edit pages, you can use them in validation rules but not as the error location for your validation.
•
Avoid referencing a roll-up summary field from a child record. The roll-up summary fields referenced from child records can have outdated values, because their parent records have not been updated. Instead, reference roll-up summary fields from parent records.
Your roll-up summary fields will always have updated values, because that rule runs after the parent value has been updated.
If you’re trying to enforce a record limit of 25 on the parent roll-up summary field, create validation rules on your child objects. When you add a child record, your validation rule on the child object can check if the count is already 25 or greater.
AND(ISNEW(), Sample.Line_Count__c >= 25)
•
Plan your implementation of roll-up summary fields carefully before creating them. Once created, you cannot change the detail object selected or delete any field referenced in your roll-up summary definition.
•
Advanced currency management affects roll-up summary fields. If your organization enables advanced currency management, delete the currency roll-up summary fields on accounts that summarize opportunity values and on opportunities that summarize custom object values. Otherwise, the fields continue to display with an invalid roll-up summary icon because their values are no longer calculated.
•
Automatically derived fields, such as current date or current user, aren’t allowed in a roll-up summary field. Forbidden fields include formula fields containing functions that derive values on the fly, such as DATEVALUE, NOW, and TODAY. Formula fields that include related object merge fields are also not allowed in roll-up summary fields.
•
When you refer to a roll-up summary field in a list view or report, you can’t use certain qualifiers, including:
– Starts with
– Contains
– Does not contain
– Includes
– Excludes
– Within
SEE ALSO:
234
Extend Salesforce with Clicks, Not Code Customize Fields
Defining Roll-Up Summaries
Define roll-up summary fields on the object that is on the master side of a master-detail relationship.
If a relationship does not already exist, first create a master-detail relationship between the master object that displays the value and the detail object containing the records you are summarizing.
To define a roll-up summary field:
1. Create a custom field on the object where you want the field displayed. Summary fields summarize the values from records on a related object, so the object on which you create the field should be on the master side of a master-detail relationship. For instructions on creating a custom field, see
Create Custom Fields on page 131.
2. Choose the
Roll-Up Summary
field type, and click Next.
3. Enter a field label and any other attributes. Click Next.
4. Select the object on the detail side of a master-detail relationship. This object contains the records you want to summarize.
5. Select the type of summary:
Type
COUNT
SUM
MIN
MAX
Description
Totals the number of related records.
Totals the values in the field you select in the
Field to Aggregate option. Only number, currency, and percent fields are available.
Displays the lowest value of the field you select in the
Field to
Aggregate
option for all directly related records. Only number, currency, percent, date, and date/time fields are available.
Displays the highest value of the field you select in the
Field to
Aggregate
option for all directly related records. Only number, currency, percent, date, and date/time fields are available.
EDITIONS
Available in: both Salesforce
Classic and Lightning
Experience
Available in: Contact
Manager, Group,
Professional, Enterprise,
Performance, Unlimited,
Developer, and
Database.com Editions
USER PERMISSIONS
To view roll-up summary field definitions:
•
View Setup and
Configuration
To edit roll-up summary field definitions:
•
Customize Application
6. Enter your filter criteria if you want a selected group of records in your summary calculation. If your organization uses multiple languages, enter filter values in your organization's default language.
When you use picklists to specify filter criteria, the selected values are stored in the organization's default language. If you edit or clone existing filter criteria, first set the
Default Language
on the Company Information page to the same language that was used to set the original filter criteria. Otherwise, the filter criteria may not be evaluated as expected.
7. Click Next.
8. Set the field-level security to determine whether the field should be visible for specific profiles, and click Next.
9. Choose the page layouts that should display the field. The field is added as the last field in the first two-column section on the page layout. For user custom fields, the field is automatically added to the bottom of the user detail page.
10. Click Save to finish or Save & New to create more custom fields.
SEE ALSO:
235
Extend Salesforce with Clicks, Not Code Customize Fields
Lookup Filters
Improve user productivity and data quality with lookup filters. Lookup filters are administrator settings that restrict the valid values and lookup dialog results for lookup, master-detail, and hierarchical relationship fields.
Administrators specify the restrictions by configuring filter criteria that compare fields and values on:
•
The current record (source)
•
The lookup object (target)
•
The user's record, permissions, and role
•
Records directly related to the target object
EDITIONS
Available in: both Salesforce
Classic and Lightning
Experience
Available in: All Editions except for Database.com.
USER PERMISSIONS
For example, you can:
•
Restrict the
Account Name
field on opportunities to allow only accounts with a record type of Customer, filtering out Partner and Competitor.
•
Restrict the
Account Name
field on opportunities to allow only active accounts.
To manage lookup filters:
•
Customize Application
•
Restrict the
Contact
field on cases to allow only contacts associated with the account specified in the
Account Name
field on the case record.
•
Restrict the
Account Name
field on cases to allow only users with the “International Sales” profile to create or edit cases for accounts outside the United States.
Tip: When you define a lookup filter, optionally click
Insert Suggested Criteria
to choose from a list of lookup filter criteria that Salesforce suggests based on the relationships between objects in your org.
Administrators can make lookup filters required or optional.
•
For fields with required lookup filters, only values that match the lookup filter criteria appear in the lookup dialog. Also, users can't save invalid values manually typed in the field when editing the record. If a user tries to save an invalid value, Salesforce displays an error message, which administrators can customize.
•
For fields with optional lookup filters, only values that match the lookup filter criteria appear in the lookup dialog initially; however, users can click the Show all results link in the lookup dialog to remove the filter and view all search result values for the lookup field. Also, optional lookup filters allow users to save values that don't match the lookup filter criteria, and Salesforce does not display an error message if a user tries to save such values.
Lookup filter criteria can compare fields on the source object with different types of fields on the target object as long as the fields are compatible.
Source Object Field Type
Currency
Date
Date/Time
Hierarchy
Lookup
Master-Detail
Number
Compatible Target Object Field Types
Currency, Roll-Up Summary
Date, Date/Time, Roll-Up Summary
Date, Date/Time, Roll-Up Summary
Hierarchy, Lookup, Master-Detail
Hierarchy, Lookup, Master-Detail
Lookup, Hierarchy, Master-Detail
Number, Percent, Roll-Up Summary
236
Extend Salesforce with Clicks, Not Code
Percent
Picklist
Roll-Up Summary
Supported Objects
Salesforce supports lookup filters on relationship fields that point to:
•
Accounts
•
Assets
•
Badges
•
Badges Received
•
Business Hours
•
Campaigns
•
Cases
•
Contacts
•
Content Folders
•
Contracts
•
Endorsements
•
Entitlements
•
Ideas
•
Leads
•
Opportunities
•
Order Products
•
Orders
•
Price Books
•
Products
•
Quotes
•
Service contracts
•
Skill Users
•
Skills
•
Social Personas
•
Solutions
•
Thanks
•
User Provisioning Accounts
•
User Provisioning Logs
•
User Provisioning Requests
•
Users
•
Work Order Line Items
•
Work Orders
Number, Percent, Roll-Up Summary
Text, Text Area, Email, URL
Currency, Number, Date, Date/Time, Roll-Up Summary
Customize Fields
237
Extend Salesforce with Clicks, Not Code Customize Fields
•
Zones
•
Custom objects
Delete or Deactivate Lookup Filters
View a List of Lookup Filters for a Target Object
Considerations for Lookup Filters
Notes on Using Lookup Filters with Person Accounts
Define Lookup Filters
1. You can create lookup filters for new relationship fields in step 3 of the custom field wizard.
EDITIONS
a. From the management settings for the field’s object, go to Fields.
b. Click Edit next to the name of the lookup or master-detail relationship field to which you want to apply the filter.
Available in: both Salesforce
Classic and Lightning
Experience
2. In the Lookup Filter Options section, click Show Filter Settings.
3. Specify the filter criteria a record must meet to be a valid value. To specify criteria, click Insert
Suggested Criteria and choose from a list of suggested criteria, or manually enter your own criteria. To enter your own criteria:
Available in: All Editions except for Database.com.
USER PERMISSIONS
a. In the first column, click the lookup icon or start typing in the text box and select a field.
b. In the second column, select an operator.
To define lookup filters:
•
Customize Application
c. In the third column, select
Value
if Salesforce should compare the field in the first column with a static value, or select
Field
if Salesforce should compare the field in the first column with the value of another field.
d. In the fourth column, enter the value or select the field that Salesforce should compare with the field in the first column.
Note:
•
Click Add Filter Logic to add Boolean conditions.
•
Select a suggested field from the Field text box. You can only select fields on the current record, the lookup object, or the user record. You can also choose related fields that are one relationship away from the lookup object. Salesforce assists you by listing the available fields and relationships when you click the lookup icon or click inside the text box.
•
Lookup filter criteria can compare fields of different types as long as they are compatible.
4. Specify whether the filter is required or optional. For fields with optional lookup filters, only values that match the lookup filter criteria appear in the lookup dialog initially; however, users can click the Show all results link in the lookup dialog to remove the filter and view all search result values for the lookup field. Also, optional lookup filters allow users to save values that don't match the lookup filter criteria, and Salesforce does not display an error message if a user tries to save such values.
Note: In Lightning Experience, all filters are required, even if admins specify them as optional in Setup. There’s no Show all
results view.
238
Extend Salesforce with Clicks, Not Code Customize Fields
For required lookup filters, specify whether you want Salesforce to display the standard error message or a custom message when a user enters an invalid value.
5. Optionally, enter text to display in the lookup search dialog. Consider text that guides users in their searches and explains the business rule that the lookup filter implements.
6. Leave
Enable this filter
selected.
7. Save your changes.
SEE ALSO:
Considerations for Lookup Filters
Find Object Management Settings
Delete or Deactivate Lookup Filters
1. From the managements settings for the relationship field’s object, go to Fields.
2. Scroll to the Custom Fields & Relationships related list.
3. Click the name of the field containing the lookup filter.
4. Click Edit.
5. To deactivate the lookup filter, deselect
Enable this filter
, then save your changes.
Deactivating a lookup filter preserves the lookup filter configuration but:
•
Prevents it from applying to the relationship field
•
Prevents it from impacting the cross-object references limit
•
Removes it as a dependency for fields referenced in the lookup filter criteria
6. To delete the lookup filter, click Clear Filter Criteria, then save your changes.
Deleting a lookup filter permanently removes it. You can’t recover deleted lookup filters.
EDITIONS
Available in: both Salesforce
Classic and Lightning
Experience
Available in: All Editions except for Database.com.
USER PERMISSIONS
To define lookup filters:
•
Customize Application
SEE ALSO:
Considerations for Lookup Filters
Find Object Management Settings
239
Extend Salesforce with Clicks, Not Code Customize Fields
View a List of Lookup Filters for a Target Object
You can quickly see a list of all of the lookup filters that restrict the values of each target object. This is useful when creating similar filters for a target object. Also, lookup filters that reference fields on related objects count against the cross-object reference limit, which is the number of unique relationships allowed for a target object. The Related Lookup Filters list lets you see which lookup filters might impact that limit.
To see which lookup filters affect the limit for a particular target object, from the management settings for the object, go to Related Lookup Filters.
SEE ALSO:
Considerations for Lookup Filters
EDITIONS
Available in: both Salesforce
Classic and Lightning
Experience
Available in: All Editions except for Database.com.
USER PERMISSIONS
To define lookup filters:
•
Customize Application
Dependent Lookups
A dependent lookup is a relationship field with a lookup filter
that references fields on the source object. For example, you can configure the case
Contact
field to only show contacts associated with the account selected in the case
Account Name
field.
When a user changes the value of a referenced field on the source object, Salesforce immediately verifies that the value in the dependent lookup still meets the lookup filter criteria. If the value doesn't meet the criteria, an error message is displayed and users can't save the record until the value is valid.
If the referenced field on the source object is a lookup, master-detail, or hierarchy field, users can't change its value by typing. Instead, users must click the lookup icon and select a value in the lookup search dialog.
Tip:
Dependent lookups are supported in Visualforce pages.
EDITIONS
Available in: both Salesforce
Classic and Lightning
Experience
Available in all editions
USER PERMISSIONS
To manage dependent lookups:
•
Customize Application
SEE ALSO:
240
Extend Salesforce with Clicks, Not Code Customize Fields
Considerations for Lookup Filters
•
On the Fields page, the icon indicates all fields with active lookup filters. The icon indicates that the lookup filter is required.
EDITIONS
•
The lookup filters you create in Salesforce also appear in the partner portal and Customer Portal.
•
Lookup filters are case-sensitive.
Available in: both Salesforce
Classic and Lightning
Experience
•
If you convert a required lookup filter with a custom error message to be optional, Salesforce deletes the message.
Available in: All Editions except for Database.com.
•
If you create a lookup filter that invalidates an existing value for that field, the value persists.
However, when a user edits the record, Salesforce displays an error message and requires the user to change the invalid value before saving.
USER PERMISSIONS
•
You can’t save changes that cause required lookup filters on related records to contain invalid values.
•
Versions 16.0 and higher of the Salesforce API support lookup filters. Lookup filters are enforced when you load data through the API.
To manage lookup filters:
•
Customize Application
•
If you configure a lookup filter to show inactive users only, the relationship field has no valid options. Inactive users are never valid for relationship fields that point to the User object.
•
If you create a filtered lookup on a field that looks up to another object, both objects must be deployed into the organization at the same time.
•
Lookup field filters don’t work if the field criteria include a master-detail relationship field.
•
Salesforce doesn’t display an error message if the value of a controlling field invalidates the value of a dependent master-detail relationship field.
•
Dependent lookups are supported in Visualforce pages.
•
In Lightning Experience, a lookup filter doesn’t work if a field referenced in the filtered lookup isn't added to the page layout.
Spanning Relationships in Lookup Filters
Filter criteria can include fields directly related to the target object (one level only). For example, on a lookup field pointing to contacts, a lookup filter can reference fields on the account related to the contact via the Account Name relationship field. The lookup field can also reference fields on the contact related to the contact via the Reports To relationship field.
For required lookup filters, each field referenced on a related lookup object counts against the number of unique relationships allowed for the referenced object, not the source object. For example, the two unique relationships described above count against the number allowed for the Contact object. Optional lookup filters don't count against the limit on the number of unique relationships allowed per object.
To see which lookup filters affect the limit for a particular target object, from the management settings for the object, go to Related
Lookup Filters.
Lookup Filters vs. Validation Rules
Validation rules and lookup filters achieve similar ends, but offer different advantages. Use a lookup filter if:
•
You want to improve user efficiency by limiting the number of available options in a lookup search dialog.
•
You want to improve user efficiency by automating filters on lookup search dialogs that your users manually set.
Use a validation rule if:
•
You're close to the maximum number of lookup filters allowed.
241
Extend Salesforce with Clicks, Not Code Customize Fields
•
You must implement a complex business rule that requires you to use a formula. Formulas can reference fields that basic filter criteria can't reference, such as fields on the parent of the source object. Formulas can also use functions. For example, use
ISNEW
if the rule should only apply on record creation, or
ISCHANGED
if the rule should apply when a field changes.
SEE ALSO:
Notes on Using Lookup Filters with Person Accounts
If your organization uses person accounts, note the following:
EDITIONS
•
Person Accounts don't support Contact filters; however, Person Accounts support Account filters. For example, if the
Account
field has a dependent lookup filter that's added to a Person
Account, dependent lookups are supported. If the
Contact
field has a dependent lookup filter that's added to a Person Account, dependent lookups isn't supported.
Available in: both Salesforce
Classic and Lightning
Experience
•
Lookup filter criteria on
Account Name
only apply to business accounts, not person accounts.
For example, if your lookup filter criteria is
Account Name does not contain book
, business accounts with “book” in the name, such as John’s Bookstore, are not valid, but person accounts with “book” in the name, such as John Booker, are valid and appear in the lookup
Available in: All Editions except for Database.com.
dialog for the
Account
field. If you need to filter on the name for a person account, use the
First Name
or
Last Name fields instead.
•
Use the
Is Person Account
field in your lookup filter criteria to restrict the valid values of a lookup field to one type of account
(either person accounts or business accounts). For example, to restrict a lookup to only person accounts, include the following in your lookup filter criteria:
Is Person Account equals True
.
•
You can't package lookup filters that reference standard fields specific to person accounts, such as the
and
Title
fields.
SEE ALSO:
Lookup Filters Best Practices
Custom Help
Define custom help for fields with lookup filters to let users know about the business rule the filter enforces. For example, if the lookup filter restricts the
Account Name
on opportunities to only allow active accounts, define custom help that states
You can only associate active accounts with opportunities.
Error Messages
Customize lookup filter error messages to guide users who type invalid values. For example, if the lookup filter restricts the
Account Name
on opportunities to only allow active accounts, define an error message that states
Value doesn't exist or isn't an active account.
EDITIONS
Available in: both Salesforce
Classic and Lightning
Experience
Available in: All Editions except for Database.com.
Important: Salesforce translates the standard error message for required lookup filters, but not custom error messages. Use the Translation Workbench to translate lookup filter custom error messages. To restore the standard error message after modifying it, click Reset to default message.
242
Extend Salesforce with Clicks, Not Code Customize Fields
Working with Master-Detail Relationship Fields
When creating a lookup filter on a master-detail relationship field, verify that the current values of the field on all of the detail records meet the criteria you specify. If you specify criteria that an existing value doesn't meet, Salesforce prevents the user from saving changes to the detail record. If this occurs, the user must first modify the value on the master record to meet the criteria. For example, consider a custom object with a master-detail relationship field that points to accounts. If you define a lookup filter that excludes all accounts with a
Create Date
before 01/01/2009, verify that no existing records of that custom object have a master-detail relationship with any account created before 2009. A quick way to do this is to create a report that shows all accounts with a
Create
Date
before 01/01/2009.
Profile-Based Lookup Filters
Use
Current User Profile: ID
in filter criteria to define different filter criteria for different users, or to let administrators enter values that don't match the criteria. Avoid using
Current User Profile: Name
due to technical limitations on standard profiles.
If you enter
Current User Profile: Name
or
Profile: Name
in the Field column of your lookup filter criteria,
Salesforce displays a lookup icon in that row. Click the lookup icon to select from a list of existing profiles rather than typing profile names.
Record IDs vs. Record Names
To reference a specific record in filter criteria, use the ID of the record instead of its name. IDs are always unique whereas names are not.
Testing
After creating a lookup filter, test it to make sure it is not too restrictive. Depending on their permissions, some users may have read-only access to some relationship fields; ensure your lookup filters don't prevent those users from editing records critical to their job functions.
Dependent Lookups on Page Layouts and Mini Page Layouts in the Console
When designing page layouts with dependent lookups:
•
If a dependent lookup is above its controlling field on a layout, make its lookup filter optional or redesign the layout. Moving a required dependent lookup above its controlling field may confuse users who typically start from the top of a page when entering data.
•
Ensure that both the controlling and dependent fields are visible so users can correct invalid values.
Lookup Filters and the Lookup Filter Fields Search Layout
Don’t reference the same fields in both lookup filter criteria and the Lookup Filter Fields search layout. Users might assume that results from their custom search override administrator-controlled lookup filters.
SEE ALSO:
243
Extend Salesforce with Clicks, Not Code Customize Fields
Lookup Filter Examples
Record Types in Lookup Filters
If the value of a relationship field should only consist of records with a particular record type
, specify the record type in a lookup filter. For example, if the
Account Name
field on opportunities should only have accounts with a Customer Account custom record type, define the following lookup filter to restrict users to only creating or editing opportunities associated with accounts that have a Customer Account record type, excluding accounts with Partner Account and Competitor
Account record types:
Filter Criteria
Account Name: Account Record Type equals value Customer
Account
Custom Error Message
Account does not exist or is not a customer account.
Lookup Window Text
You can only associate customer accounts to an opportunity.
Search results only display customer accounts.
EDITIONS
Available in: both Salesforce
Classic and Lightning
Experience
Available in: All Editions except for Database.com.
Record types available in:
Professional, Enterprise,
Performance, Unlimited, and Developer Editions
USER PERMISSIONS
To define lookup filters:
•
Customize Application
Record Status in Lookup Filters
If the value of a relationship field should only consist of records with particular status, specify the status in a lookup filter. For example, consider a Job Application object with a relationship field that points to the
Position
object. If the relationship field should only have open positions, define the following lookup filter to restrict users to only creating or editing job applications for positions with the
Status
field set to Open:
Filter Criteria
Position: Status equals value Open
Custom Error Message
Position does not exist or is not an open position.
Lookup Window Text
You can associate only open positions with job applications. Search results display open positions only.
Profiles in Lookup Filters
When a business rule does not apply to users with every profile, use the
Current User Profile
global variable fields to define lookup filters that only affect users with a particular profile.
For example, the following lookup filter on the Case object
Account Name
field restricts users with a “Domestic Sales” profile to only creating or editing opportunities associated with accounts that have a billing country of “USA” while allowing other users to associate opportunities with any account:
Filter Criteria
1.
Current User Profile: Name equals value Domestic Sales
2.
Account Name: Billing Country equals value USA
3.
Current User Profile: Name not equal to value Domestic Sales
244
Extend Salesforce with Clicks, Not Code Customize Fields
Filter Logic
(1 AND 2) OR 3
Custom Error Message
Account does not exist or the account billing country is not USA. Domestic sales reps can only create opportunities for accounts in the United States.
Lookup Window Text
Search results show only United States accounts in the for domestic sales representatives.
You can modify the above example to simultaneously restrict users with a “Global Sales” custom profile to only associating opportunities to accounts with a non-US billing country:
Filter Criteria
1.
Current User Profile: Name equals value Global Sales
2.
Account Name: Billing Country not equal to value USA
3.
Current User Profile: Name equals value Domestic Sales
4.
Account Name: Billing Country equals value USA
5.
Current User Profile: Name not equal to value Global Sales, Domestic Sales
Filter Logic
(1 AND 2) OR (3 AND 4) OR 5
Custom Error Message
Account does not exist or the account billing country is not in your sales area.
Sales reps can only create opportunities for accounts in their sales area.
Lookup Window Text
Search results only display accounts in your region.
Important: If you do not include line 5 in the filter criteria, users who are not in Global Sales or Domestic Sales cannot select or save any values on account records.
Roles in Lookup Filters
When a business rule does not apply to users in every role, use the
Current User Role
global variable fields to define lookup filters that only affect users with particular roles. For example, in a recruiting application that has a Position object with a lookup field to a Compensation Package object, you can restrict users from editing or creating positions that have an executive compensation plan unless they are executive administrators or vice presidents. To do this, define the following lookup filter on the Position object
Compensation Package Name
field:
Filter Criteria
1.
Current User Role: Name does not start with value VP
2.
Current User Role: Name does not equal value Executive Administrator
3.
Compensation Package: Plan Type does not equal value Executive
4.
Current User Role: Name starts with value VP
5.
Current User Role: Name equals value Executive Administrator
Filter Logic
((1 OR 2) AND 3) OR (4 OR 5)
245
Extend Salesforce with Clicks, Not Code Customize Fields
Custom Error Message
The compensation plan does not exist, or you have selected an executive compensation plan but do not have access to create executive positions.
Lookup Window Text
Search results only display compensation plans that are relevant to positions you are allowed to create.
Important: Include the condition you are testing and the opposite condition. In this example, lines 1, 2, and 3 of the filter criteria ensure that users who are not VPs or Executive Administrators cannot select Executive compensation plans, while lines 4 and 5 ensure that VPs and Executive Administrators can select Executive compensation plans.
Blank Values in Lookup Filters
Your lookup filter criteria might reference a field that users often leave blank. You can design your lookup filter criteria to accept blank values by using the Add Filter Logic in the filter criteria to create an OR condition. For example, if you have a
Partner Contact custom field on opportunities, restrict the field to only allow contacts that are associated to an account with a Partner Account record type, or private contacts not associated with any account.
Filter Criteria
1.
Partner Contact: Account: Account Record Type equals value Partner Account
2.
Partner Contact: Account: Account Name equals value
Filter Logic
1 OR 2
Custom Error Message
The partner contact must be associated with a partner account, or must be a private contact.
Lookup Window Text
Search results only display contacts from partner accounts or your private contacts.
User IDs in Lookup Filters
Using user IDs in optional lookup filters can significantly improve user efficiency by first showing lookup search dialog results that are most relevant to the user while still allowing users to see all results if necessary. For example, on a lookup field to accounts, you can create an optional lookup filter that restricts the search results to accounts that the user owns in the search lookup dialog results. If the user is looking for an account that someone else owns, the user can remove the filter.
Filter Criteria
Current User: User ID equals Field Account: Owner ID
Lookup Window Text
By default, search results only display accounts you own. To search all accounts, click “Show all results.”
Simple Dependent Lookups
If the value of a relationship field should depend on the value of another relationship field on the current record, specify the field to field comparison in the criteria. For example, if the case
Contact Name
field should only have contacts associated to the account specified in the case
Account Name
field, use the following lookup filter:
246
Extend Salesforce with Clicks, Not Code Customize Fields
Filter Criteria
Contact Name: Account ID equals field Case: Account ID
Custom Error Message
Contact does not exist or is not associated to the case account.
Lookup Window Text
Search results only display contacts associated to the case account.
Note:
When comparing lookup fields in lookup filter criteria, Salesforce always uses the ID of the relationship field, not the name.
Complex Lookup Filters and Dependent Lookups
Achieving complex business rules with lookup filters often involves combing your rules with filter logic and fields of various types. For example, consider an app for booking conference rooms that has the following data model:
Object
Meeting
Fields
•
Meeting Name
•
Office
lookup to the Office object
•
Projector Required
checkbox
•
Number of Participants
number field
•
Conference Room
lookup to the Conference Room object
Conference Room
•
Conference Room Name
•
Has Projector
checkbox
•
Number of Seats Available
number field
•
Conference Room Location
lookup to the Office object
Office
•
Office Name
The following lookup filter on the meeting
Conference Room
field restricts the valid values to conference rooms that have a projector if the meeting requires one, as well as the necessary number of seats:
Filter Criteria
1.
Meeting: Projector Required equals field Meeting Conference Room: Has Projector
2.
Meeting: Projector Required equals value False
3.
Conference Room: Number of Seats Available greater or equal field Meeting: Number of Participants
Filter Logic
(1 OR 2) AND 3
Custom Error Message
Conference room not found or is insufficient for your meeting.
247
Изтегляне
Реклама