7

Like many folk out there, I want to remove the requirement that a new Lead object needs to have something in the Company field. From various discussions (like this one) it looks like it is not possible to make it a non-required field.

BUT, I have worked on an instance where the following piece of test code runs perfectly fine:

Lead freshLead = new Lead();
freshLead.Email = 'nomatch@example.com';
freshLead.LeadSource = 'Email';
freshLead.FirstName = 'John';
freshLead.LastName = 'Doe';
// note: no freshLead.Company = 'Unknown';
insert freshLead;

How is this done?

  • Odd, using execute anonymous on V29: insert new Lead(lastName='foo', email='foo@bar.com'); I get "DMLException Required Fields are Missing: Company". Unlimited Edition org. I would agree with Greenstork that a beforeInsert trigger must be defaulting the company field if null – cropredy Nov 25 '13 at 19:01
5

You can make the field not required by requesting Person Accounts be enabled in your organization. Failing that, there would necessarily be a before insert trigger in play. It may be in a managed package installed, in which case you may not be able to determine the origin of the update.

| improve this answer | |
  • 1
    ah, but of course. A lead w/o a company won't convert to an Account (name is required field) unless Person Accounts are enabled – cropredy Nov 26 '13 at 0:43
  • 1
    That's it. The org in question has Person Accounts enabled. Thanks! – JannieT Nov 26 '13 at 9:11
1

You would need a before insert trigger on Lead that populates the Company field if it is null.

| improve this answer | |
  • That is a bright idea that I didn't think of. But, there is definitely no before insert trigger on the Lead in that org. The above code snippet is on Lead (after insert) – JannieT Nov 25 '13 at 14:45

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.