Set Default Opportunity Name
Not Started

Before You Begin:
1. If you haven't already, deploy the pre-requisite Flows: Flow-Into-Apex Package
2. Click on "Run Tests Only" before making any changes. This ensures the Flow works as is without updating the challenge progress.
3. Deactivate the Flow & rebuild as Apex
4. Hit the "Submit" button when you're ready to have your final solution evaluated and challenge progress updated

Flow To Convert
Set Default Opportunity Name

Description
Whenever an Opportunity record is created, override the Opportunity's record name with the following naming convention: [Close Date Year] [Opportunity's Account Name] Opportunity

Object & Trigger Event
Opportunity, on Before Insert

Concepts to learn
  • Simple update of records before insert
  • String Concatenation
  • Use of the year() method

Resources

YouTube Videos

Salesforce Documentation



Challenge Cheat Codes
  • In Apex, you can use the + operator to merge multiple strings into one. This is known as string concatenation.
    • Example 1: "Opportunity Name: " + oppty.Name
    • Example 2: "The " + oppty.Name + " opportunity is in the following stage: " + oppty.StageName
  • You might think an update statement is needed here, but in triggers, you can directly modify fields on records in Trigger.new. This is similar to how the updates in the flow are handled. Salesforce automatically saves changes to these records, so no extra DML is required.
  • Fields on related records aren’t always directly accessible in triggers. For example, you might not have the ability to access Account fields on an Opportunity record. You can use a SOQL query to retrieve Account field values, and it might be helpful to store the information you need in a map.