Problem: I have a requirement to make First Name fields (On User and Contact objects) required and to make the Last Name fields on both objects not required. Given these are standard fields, I obviously cannot modify them.

My Question: I know I can use validation rules to make the First Name required on both objects but, how would I make Last Name not required? I could also create custom fields, but I feel like that is not best practice especially with the Name field. Is there a best practice solution for this requirement? Has anyone encountered this issue?

Suggestions welcome. Thanks in advance!

  • can you not default Contact.LastName to n/a? It is a fool's errand to try and undermine the Required attribute for Contact.LastName – cropredy Apr 16 '20 at 18:19
  • You can generate a bogus Last Name prior to the record being inserted. Trigger is one possibility for doing so, there may be other options depending on your solution architecture. – identigral Apr 16 '20 at 18:20

Long story short, you cannot make LastName not required in either of those objects. The hardest part is that a before trigger won't help you if the record insert/update is coming from the screen.

If you look at the Salesforce Order of Execution doc, here, you'll see that step 2 will validate the required fields at the GUI level before the before triggers even execute (that'd be Step 4).

Frankly, the only way I was ever able to solve this is by doing one of two things, and both of them are horrible.

  1. Teach users to put a period (".") and then use my before trigger to change it to something different
  2. Override the standard layout (you can't do that for users) or offer an alternative custom form and default the Last Name field to something using code.

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.