How to Modify the Leads UI for Sales Prospects

Since leads for sales prospects represent contacts with potential buying interest, some customers want to hide the lead name from the UI. Instead, they want to set the primary contact field as required, and use the primary contact as the lead identifier.

Use application composer and object triggers to cater for these configuration tasks:

  • Set the Primary Contact field as required

  • Mark the name field as hidden in both the create and edit lead pages

  • Automatically populate the lead name with the primary contact value when a lead is created and updated

Note: Sign in using the sales administrator role and create a sandbox and activate it.

Set Primary Contact Field as Required

Here's how to set the primary contact field as mandatory on the leads UI:
  1. Navigate to Application Composer and expand Standard Objects, then Sales Lead and then click Fields.

  2. Search for the Primary Contact field of type Dynamic Choice List.

  3. From the Edit Standard Field: Primary Contact page, under the Constraints section, select the Required check box.

  4. Click Save and Close.

Hide the Name Field

Here's how to hide the Name field on the leads UI:
  1. Navigate to Application Composer and expand Standard Objects, then Sales Lead and then click Pages.

  2. Navigate to Sales Lead > Pages > Creation Page Layout > Create a Duplicate Layout page.

  3. From the Creation Page Layout section, select Duplicate Layout from the Actions menu.

  4. In the Duplicate Layout dialog, enter Default User-Defined Layout in the New Layout Name field.

  5. Click Save and Edit.

  6. Click the Edit icon to display the Configure Detail Form.

  7. Move Name from Selected Fields list to Available Fields list.

  8. Click Save and Close, then click Done.

  9. Repeat steps 4 to 9 to edit the Details Page Layout section.

Populate the Lead Name with the Primary Contact Value

Here's how to populate the lead name with the primary contact value when a lead is created and updated:
  1. Navigate to Application Composer and expand Standard Objects, then Sales Lead and then click Server Scripts.

  2. Click the Triggers tab, and then click the Add a new Trigger icon in the Object Triggers section.

  3. In the Trigger field, select the Before Insert in Database trigger type.

  4. In the Trigger Name field, enter a name, without spaces, such as UpdatLeadOwnerOnCreate.

  5. Copy and paste the following content of the script to the Trigger Definition section:

    if(PrimaryContactName == null)
    {
      throw new oracle.jbo.ValidationException('Primary Contact is a required field. Please select a Primary Contact.') 
    }
    else
    {
      setAttribute('Name',PrimaryContactName)
    }
  6. Click Save and Close.

    Verify that you see the newly created trigger in the Object Triggers section.

  7. Next, click the Add a new Trigger icon in the Object Triggers section to create another object trigger.

  8. In the Trigger field, select the Before Update in Database trigger type.

  9. In the Trigger Name field, enter a name such as UpdatLeadOwnerOnUpdate.

  10. Copy and paste the following content of the script to the Trigger Definition section:

     if(PrimaryContactName == null)
    {
        throw new oracle.jbo.ValidationException('Primary Contact is a required field. Please select a Primary Contact.') 
    }
    else if(isAttributeChanged('PrimaryContactName') && PrimaryContactName != null)
    {
      setAttribute('Name',PrimaryContactName)
    }
  11. Click Save and Close.

    Verify that you see the newly created trigger in the Object Triggers section.

  12. Thoroughly test all changes in your sandbox environment.

  13. Publish the sandbox after successfully verifying your tests.