#trailhead
#salesforce
#salestraining
Formulas and Validations : • Formulas and Validations
Example 1: Display an Account Field on the Contact Detail Page
Record detail pages contain a ton of information, but sometimes it’s not enough. Sometimes you need more! For your first formula, let’s do something simple. Let’s take a single field from an Account and show it on a Contact using what’s called a cross-object formula. Let’s take a look.
First create a Contact. If you’ve never created a Contact before, click the App Launcher App Launcherand select Contacts. Then go to the Contacts tab and click New. Enter any value for Last Name. For Account Name, enter an existing account such as United Oil & Gas Corp. Click Save. Next we create a formula to display the account number on the Contact page.
From Setup, open the Object Manager and click Contact.
In the left sidebar click Fields & Relationships.
Click New.
For the field type, select Formula and click Next.
Call your field Account Number and select Text for the formula return type. Click Next.
In the Advanced Formula Editor, click Insert Field. Select Contact | Account | Account Number and then click Insert. Click Check Syntax. If there are no syntax errors, click Next. It’s unlikely that you’ll find a syntax error in a simple formula like this one, but it's a good idea to get in the habit of checking syntax for every formula.
The cross-object Contact formula. Account Number (Text) = Account.AccountNumber
Click Next to accept the field-level security settings, then click Save.
Congratulations, you’ve written your first formula! Now it’s time to see what you’ve done. Open the detail page for the Contact object you just created and find your new Account Number formula field. Cool!
Example 2: Display the Number of Days Until an Opportunity Closes on a Report
You can also use formula fields in reports to increase the visibility of important information. Say, for example, you wanted a report column that displays the number of days until an opportunity is closed. First, create an Opportunity to test our formula.
If you’ve never created an Opportunity before, click App Launcher and select Opportunities. go to the Opportunities tab and click New. Fill in any value for the Opportunity Name, select any Stage, and set a close date that’s at least 3 days in the future. Click Save.
Then take these steps to create a custom formula field called Days to Close on the Opportunities object with a Number return type.
From Setup, open the Object Manager and click Opportunity.
In the left sidebar click Fields & Relationships.
Click New.
Select Formula and then click Next.
In the Field Label text area, type Days to Close.
Select the Number radio button.
Click Next to open the formula editor.
To find the difference between the opportunity close date and today’s date subtract one from the other.
Click Insert Field and select Opportunity | Close Date and click Insert.
From the Insert Operator menu, select - Subtract.
But how do we tell our formula that we need today’s date? Luckily, there’s a function called TODAY() that updates to match the current date.
In the Functions menu on the right side of the editor, select TODAY.
Click Insert Selected Function.
Click Check Syntax. If there are no syntax errors, click Next.
The Days to Close formula. Days to Close (Number) = CloseDate -Today()
Click Next to accept the field-level security settings, then click Save.
Now it's time to put your new formula field in a report.
Example 3: Find Distinct Objects Using the Power of One
Organizations often want to count the number of unique objects in a report with hundreds of records. Say, for example, you have a hundred opportunities listed in a report, but only a handful of users own all these opportunities. How do you find the number of distinct users? This task sounds difficult, but it’s one of the easiest formulas you can write. It’s called the Power of One.
To write this formula, create a custom formula field on the User object. Name it Unique Users, give it a Number return type, and select 0 from the Decimal Places dropdown list. Click Next to open the formula editor. For this formula, you don’t need to insert any fields, operators, or functions. Instead, enter the number 1.
The Power of One formula. Unique Users (Number) = 1
Report with Unique Users column
Here, we have five opportunities between two distinct users. Where does our formula come in? On the Unique Users column, click the dropdown menu and select Summarize and then Sum.
Dropdown menu with Summarize and Sum selected
The number of distinct users appears at the bottom of the column. As you can see, even simple formulas provide powerful insights into your organization.
Report showing total number of unique users
00:00 Introduction
01:28 Fields Create
02:00 Formula
Смотрите видео Use Formula Fields | Formulas and Validations онлайн без регистрации, длительностью часов минут секунд в хорошем качестве. Это видео добавил пользователь Saurabh Infotech Solutions 10 Апрель 2022, не забудьте поделиться им ссылкой с друзьями и знакомыми, на нашем сайте его посмотрели 559 раз и оно понравилось 5 людям.