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
Set Primary Contact Field as Required
Here's how to set the primary contact field as mandatory on the leads UI:-
Navigate to Application Composer and expand Standard Objects, then Sales Lead and then click Fields.
-
Search for the Primary Contact field of type Dynamic Choice List.
-
From the Edit Standard Field: Primary Contact page, under the Constraints section, select the Required check box.
-
Click Save and Close.
Hide the Name Field
Here's how to hide the Name field on the leads UI:-
Navigate to Application Composer and expand Standard Objects, then Sales Lead and then click Pages.
-
Navigate to
page. -
From the Creation Page Layout section, select Duplicate Layout from the Actions menu.
-
In the Duplicate Layout dialog, enter
Default User-Defined Layout
in the New Layout Name field. -
Click Save and Edit.
-
Click the Edit icon to display the Configure Detail Form.
-
Move Name from Selected Fields list to Available Fields list.
-
Click Save and Close, then click Done.
-
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:-
Navigate to Application Composer and expand Standard Objects, then Sales Lead and then click Server Scripts.
-
Click the Triggers tab, and then click the Add a new Trigger icon in the Object Triggers section.
-
In the Trigger field, select the Before Insert in Database trigger type.
-
In the Trigger Name field, enter a name, without spaces, such as
UpdatLeadOwnerOnCreate
. -
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) }
-
Click Save and Close.
Verify that you see the newly created trigger in the Object Triggers section.
-
Next, click the Add a new Trigger icon in the Object Triggers section to create another object trigger.
-
In the Trigger field, select the Before Update in Database trigger type.
-
In the Trigger Name field, enter a name such as
UpdatLeadOwnerOnUpdate
. -
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) }
-
Click Save and Close.
Verify that you see the newly created trigger in the Object Triggers section.
-
Thoroughly test all changes in your sandbox environment.
-
Publish the sandbox after successfully verifying your tests.