As the title asks, trying to bypass required lead fields on record create so the end user doesn't have to fill out last name or company. I only want them to fill out email.

What's best route?

  1. Could a before insert trigger work here to populate dummy filler values into 'company' and 'last name'? I plan to hide company filed altogether and we can always update last name as it's acquired organically.
  2. would a lighting component with a custom new lead form be the best approach?

Unfortunately, you cannot address this with a trigger or other automation, because the system's validation for required fields takes place prior to the execution of before triggers. From Triggers and Order of Execution:

  1. Loads the new record field values from the request and overwrites the old values. If the request came from a standard UI edit page, Salesforce runs system validation to check the record for:
    • Compliance with layout-specific rules
    • Required values at the layout level and field-definition level
    • Valid field formats
    • Maximum field length

(Emphasis mine), followed by

  1. Executes all before triggers.

Your solutions will all be at the user-interface level, and one option would definitely be a Lightning component to support Lead creation.

You don't necessarily need to go all that way, though. This objective sounds to me like it could be achievable using a Quick Action that prefills some placeholder value for required fields you don't want the user to have to enter, which would prevent you from having to write any code if you're comfortable with guiding users into that creation flow.

  • I went the component route as the UI required clean/simple interface. It creates a lead, and fills dummy files if required fields are null. It works well--thanks! – sfdcstack Dec 18 '18 at 21:46

Yes, you can perform a Global action on Lead object and in the page layout remove mandatory fields like Name and Company, keep only Email field. Here you don't need to prefill those mandatory fields even.

This global action can be used from publisher layout.

For more information refer Create Global Quick Actions trailhead module

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.