For this book, we will use the world of Formula 1 motor car racing as the basis for a packaged application that we will build together. Formula 1 is, for me, the motor sport that is equivalent to enterprise application software, due to its scale and complexity. It is also a sport that I follow. My knowledge of both of these fields helped me when building the examples that we will use.
We will refer to our application as FormulaForce throughout this book, though please keep in mind Salesforce's branding policies when naming your own application, as they prevent the use of the word "Force" in company or product titles.
This application will focus on the data collection aspects of races, drivers, and their many statistics, utilizing platform features to structure, visualize, and process this data in both historic and current contexts.
Run the following commands to create a Salesforce DX project for your application and create a special org known as a scratch org for you to perform your development work in. This org is given the alias "dev" and set as the project default. These orgs only last 7 days (by default, the maximum is 30 days) so be sure to synchronize regularly, as described later in this chapter:
sfdx force:project:create --projectname formulaforce
cd formulaforce
sfdx force:org:create
--definitionfile config/project-scratch-def.json
--setalias dev
--setdefaultusername
code .
The preceding code command is used as a convenience to quickly open VSCode in the current directory. From here, you can open the Integrated Terminal and continue to execute Salesforce DX CLI commands from within the IDE.
The .forceIgnore file allows you to control which aspects of the scratch org and your local files are synchronized. Later in this book, in Chapter 2, Leveraging Platform Features, we will cover permission sets as a means to configure security rather than using the less flexible profiles feature. In preparation for this, enter the following into the .forceIgnore file and save it. This stops any unwanted profile changes that you might directly or indirectly make from being synchronized with your project:
For this chapter, we will create some initial Custom Objects and Fields, as detailed in the following table. Do not worry about creating any custom tabs just yet. You can use your preferred approach for creating these initial objects. Ensure that you have opened your project's current scratch org by running the following command:
sfdx force:org:open
From within Visual Studio Code and with your project open, you can use the shortcut key combination Cmd + Shift + P on a Mac or Ctrl + Shift + P on Windows to open the Command Palette. Start typing SFDX Open and you will see the SFDX: Open Default Org command to quickly open your scratch org without typing the preceding command. You can also run other Salesforce DX commands this way, such as creating scratch orgs.
Here is a list of objects along with their field names and types:
Object
|
Field name and type
|
Season__c
|
Name (text)
|
Race__c
|
Name (text)
Season (Master Detail Lookup to Season)
|
Driver__c
|
Name (text)
|
Contestant__c
|
Name (Auto Number CONTEST-{00000000})
Race (Master Detail Lookup to Race)
Driver (Lookup to Driver)
|
The following screenshot shows the preceding objects within the Schema Builder tool, available under the Setup menu:
Once you have completed creating the preceding objects, you should synchronize them with your project:
sfdx force:source:pull
This is an important command when using Salesforce DX to ensure you always have the latest changes as a permanent record in file form. The entire project and the files representing your application can then be stored in source control from this point onward if desired. We will review these files further later.