Deriving year and month values from the opportunity close date using a formula

To simplify the format of dates for presentation and reporting, we can derive the year and month from the date element.

In this recipe, we will display a derived year and month text string for the opportunity close date, on the opportunity record detail page, calculated from the standard date field called CloseDate.

How to do it...

Carry out the following steps to derive the year and month values from the opportunity close date using a formula:

  1. Navigate to the opportunity customization setup page, by going to Your Name | Setup | Customize | Opportunities | Fields.

    Note

    Scroll down to the opportunity Custom Fields & Relationships section.

  2. Click on New.

    Note

    We are presented with the Step 1. Choose the field type page.

  3. Select the Formula option.
  4. Click on Next.

    Note

    We are presented with the Step 2. Choose output type page.

  5. Type Close Date Year Month in the Field Label textbox.
  6. Click on the Field Name. When clicking out of the Field Label textbox the Field Name is automatically filled with the value Close_Date_Year_Month.
  7. Set the formula return type as Text.
  8. Click on Next.

    Note

    We are presented with the Step 3. Enter formula page.

  9. Paste the following code in the formula editor box:
    TEXT(YEAR(CloseDate)) & " " &
    CASE( 
    MONTH(CloseDate), 
    1, "January",
    2, "February", 
    3, "March", 
    4, "April", 
    5, "May", 
    6, "June", 
    7, "July", 
    8, "August", 
    9, "September", 
    10, "October", 
    11, "November",
    12, "December", "Error!")

    This is shown in the following screenshot:

    How to do it...
  10. In the Blank Field Handling section, select the option Treat blank fields as blanks.
  11. Click on Next.

    Note

    We are presented with the Step 4. Establish field-level security page.

  12. Select the profiles to which you want to grant read access to this field via field-level security. The field will be hidden from all profiles if you do not add it to field-level security.
  13. Finally, click on Save.

How it works...

The formula field appears on the opportunity detail page.

You can see what this looks like in the following image:

How it works...
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.143.5.15