Example of Extending Pages for Leads Using Application Composer

You can extend lead pages using Application Composer. You must make your changes in a sandbox, so you can test them first.

This example demonstrates how you can extend the lead object by:

  • Adding a check box to identify strategic leads

  • Adding a Groovy script that checks if the size of the deal is greater than 1000 USD when a user saves a lead with this check box selected. If the deal is smaller than this amount, then users are prevented from saving the lead and receive an error message instead.

Create the Strategic Deal Check Box and Add the Groovy Script Validation Check

Here's how to create the Strategic Deal check box and add the validation check:

  1. Navigate to Application Composer. Select Sales Lead from the Objects panel.

  2. Under the Lead object, select the Fields link.

  3. Click the Create a custom field icon and, in the Select Field Type window, select Check box.

  4. In the Create Check box Field page, enter "Strategic Deal" as the Display Label. Leave the rest of the fields with their default values.

  5. Click Save and Close.

  6. Next augment this new check box with a Groovy script. When the user attempts to save a record with the check box selected, then the script checks if the deal size is greater than 1000. If the deal size is less than 1000, then the script displays an error and the lead isn't saved.

    Here is the Groovy logic that you can use:

    def retVal
    if (StrategicDeal_c == 'Y')
    {
     if (DealAmount >= 1000)
     {
       retVal = true
     }
     else 
     {
       retVal = false
     }   
    }
    
    if (StrategicDeal_c
     == null || StrategicDeal_c
     == 'N')
    {
     retVal = true
    }
       return(retVal)
    
  7. In the Objects panel, select Server Scripts under the Sales Lead object.

  8. In the Server Scripts Sales Lead page, select the Validation Rules tab and under Object Rules, select Action - Add to add a new validation rule.

  9. In the Create Object Validation Rule page, enter the rule name as Eval and enter a simple error message in the Error Message text region.

  10. Cut and paste the script that you have written to validate the condition.

  11. Next add this field to the sales lead application pages. In Application Composer, select the Pages link under the Sales Lead object and then select the Application Pages tab.

  12. In the Details Page Layout region, duplicate the standard layout to create a new layout to edit.

  13. Click the Edit pencil icon and select the Strategic Deal field.

  14. Clock Done and save and close Application Composer.

  15. Sign in to the application again and drill into a lead.

  16. Check if the Strategic Deal check box appears.

    This figure shows an example of the Edit Lead Summary page with the Strategic Deal check box selected.
    Edit Lead Summary page with the Strategic Deal check box selected.
  17. Enter a value less than 1000 in the Deal Size field.

  18. Select the Strategic Deal check box and click Save and Close.

    You should receive the error message that you entered in Step 9 because the deal size violates the validation rule.

  19. Reenter a value greater than 1000 in the Deal Size field and save.

    You have successfully extended a sales lead application page and added Groovy logic.