Getting ready

Carry out the following steps to create a custom object that is used for field history tracking along with custom fields to capture the current and previous values of the specified fields to be tracked:

  1. Click on the Setup gear icon in the top right-hand of the main Home page, as shown in the following screenshot:
  1. Click on Setup, as shown in the following screenshot:
  1. Navigate to the Object Manager setup page, by clicking the following: Objects and Fields | Object Manager.
  2. Click on Create.
  1. Click on Custom Object, as shown in the following screenshot:

We will be presented with the New Custom Object edit page.

  1. Type Opportunity Field History in the field Label textbox.
  2. Type Opportunity Field History in the field Plural Label textbox.
Upon clicking out of the field Label textbox, the object name changes to Opportunity_Field_History.
  1. Check the Starts with vowel sound checkbox.
  2. Optionally, enter details in the Description field.
  3. Leave the Context-Sensitive Help Setting set to Open the standard Salesforce.com Help & Training window.
  4. In the Enter Record Name Label and Format section, change the Data Type picklist to Auto Number.

We will be presented with two new fields to allow the setting of the Auto Number display format and starting number.

  1. Type OFH-{000000} in the field Display Format textbox.
  2. Type 1 in the field Starting Number textbox.
  3. Within the Optional Features section, check the Allow Reports checkbox.
  4. Leave the Object Classification section settings unchanged.
  5. Leave the Deployment Status set to Deployed.
  6. Leave the Allow Search checkbox unchecked in the Search Status settings.
  7. Leave the Object Creation Options settings unchanged.
  8. Click on Save, as shown in the following screenshot:
Having created the Opportunity Field History custom object, we will create the custom fields to store our opportunity field history tracking data.

The custom fields on the opportunity field history will be used to capture the current and previous values of the required fields to be tracked.

In this recipe, we will create the following fields for tracking the history sales stage changes for opportunity records:

Field Name

Data Type

Description

Stage Original Value

Text (255)

This is the prior value of the opportunity sales stage (stored as a text entry).

Stage New Value

Text (255)

This is the new value of the opportunity sales stage (stored as a text entry).

Opportunity

Master-Detail Relationship

This is used to link the opportunity field history to the parent opportunity record.

Note: Using a Master-Detail relationship means that if the opportunity is deleted the Opportunity Field History record is also deleted.

Carry out the following steps to create the Stage Original Value field to store the prior opportunity stage value:

  1. Click on the Setup gear icon in the top right-hand of the main Home page, as shown in the following screenshot:
  1. Click the Setup option, as shown in the following screenshot:
  1. Navigate to the custom Opportunity Field History customization setup page, by clicking the following: Objects and Fields | Object Manager | Opportunity Field History | Fields and Relationships.
  2. Locate the Fields & Relationships section on the right of the page.
  3. Click on New.

We will be presented with the Step 1. Choose the field type page.

  1. Choose Text from the Data Type options.
  2. Click on Next.

We will be presented with the Step 2. Enter the details page.

  1. Enter Stage Original Value in the Field Label textbox.
Upon clicking out of the Field Label textbox, the Field Name value changes to Stage_Original_Value.
  1. Enter 255 in the Length field.
  2. Optionally, enter details in the Description field.
  3. Optionally, enter details in the Help Text field.
  1. Click on Next, as shown in the following screenshot:

We will be presented with the Step 3. Establish field-level security page.

  1. Select the profiles to which you want to grant edit access to this field via the field-level security. The field will be hidden from all profiles if you do not add it to the field-level security.
  2. Click on Next.

We will be presented with the Step 4. Add to Page Layouts page.

  1. Select the page layouts that should include this field. The field will be added as the last field in the first two-column section of these page layouts. The field will not appear on any pages if you do not select a layout.
  2. Finally, click on Save.
  3. Click on the Setup gear icon in the top right-hand of the main Home page, as shown in the following screenshot:
  1. Click the Setup option, as shown in the following screenshot:
  1. Navigate to the custom Opportunity Field History customization setup page, by clicking the following: Objects and Fields | Object Manager | Opportunity Field History | Fields and Relationships.
  2. Locate the Fields & Relationships section on the right of the page.
  3. Click on New.

We will be presented with the Step 1. Choose the field type page.

  1. Choose Text from the Data Type options.
  2. Click on Next.

We will be presented with the Step 2. Enter the details page.

  1. Enter Stage New Value in the Field Label textbox.
Upon clicking out of the Field Label textbox, the Field Name value changes to Stage_New_Value.
  1. Enter 255 in the Length field.
  2. Optionally, enter details in the Description field.
  3. Optionally, enter details in the Help Text field.
  4. Click on Next, as shown in the following screenshot:

We will be presented with the Step 3. Establish field-level security page.

  1. Select the profiles to which you want to grant edit access to this field via the field-level security. The field will be hidden from all profiles if you do not add it to the field-level security.
  2. Click on Next.

We will be presented with the Step 4. Add to Page Layouts page.

  1. Select the page layouts that should include this field. The field will be added as the last field in the first two-column section of these page layouts. The field will not appear on any pages if you do not select a layout.
  2. Finally, click on Save.

Carry out the following steps to create the opportunity relationship field to associate the opportunity field history to the opportunity record:

  1. Click on the Setup gear icon in the top right-hand of the main Home page, as shown in the following screenshot:
  1. Click the Setup option, as shown in the following screenshot:
  1. Navigate to the custom Opportunity Field History customization setup page, by clicking the following: Objects and Fields | Object Manager | Opportunity Field History | Fields and Relationships.
  2. Locate the Fields & Relationships section on the right of the page.
  3. Click on New.

We will be presented with the Step 1. Choose the field type page.

  1. Choose Master-Detail Relationship from the Data Type options.
  2. Click on Next.

We will be presented with the Step 2. Choose the related object.

  1. Choose Opportunity from within the Related To picklist field.
  2. Click on Next.

We will be presented with the Step 3. Enter the label and name for the lookup field.

  1. Accept the default Opportunity in the Field Label field.
  2. Accept the default Opportunity in the Field Name field.
  3. Optionally, enter details in the Description field.
  4. Optionally, enter details in the Help Text field.
  5. Leave the Child Relationship Name field set to Opportunity_Field_History.
  6. Leave the Sharing Setting set to Read/Write: Allows users with at least Read/Write access to the Master record to create, edit, or delete related Detail records.
  1. Click on Next, as shown in the following screenshot:

We will be presented with the Step 4. Establish field-level security for reference field.

  1. Select the profiles to which you want to grant edit access to this field via the field-level security. The field will be hidden from all profiles if you do not add it to the field-level security.
  2. Click on Next.

We will be presented with the Step 5. Add reference field to Page Layouts page.

  1. Select the page layouts that should include this field. The field will be added as the last field in the first two-column section of these page layouts. The field will not appear on any pages if you do not select a layout.
  2. Click on Save.

We will be presented with the Step 6. Add custom related lists page.

  1. Select the page layouts that will include the field within the related lists.
Because this field is a Master-Detail relationship, the field is required as part of the related list.
  1. Finally, click on Save.

Now that we have created a custom object Opportunity Field History for the field history tracking along with custom fields to capture the current and previous values of the specified fields to be tracked. We can now configure the Lightning Process Builder to trigger and insert new tracing records.

..................Content has been hidden....................

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