Is it possible to have a lookup field on a custom object in a way that the user could enter a new value?

For example, let's say I've got object A__c and I have a field on that object called Description__c which is a lookup field on Products.

With the standard lookup field if I enter a value that doesn't exist in the lookup it throws an error.

Is this possible? Is it possible to enter a value that doesn't exist without getting an error?

Or do I need two fields?

  • For a standard lookup, if quick create is enabled (don't do it) when the lookup is clicked there will be an option to create a new record. Otherwise you will have to roll your own. Keep in mind that quick create is a global setting and DOSE NOT respect validation rules, required fields (page layout), etc.
    – Eric
    May 11 '17 at 0:54

Lookup field always validates correct object type and you can update the lookup field value with the recordId, e.g ProductId if that refers to Product lookup

In the UI, with the standard lookup field if you enter a value that doesn't exist in the lookup it throws an error.

Error: No matches found.

Through the API, if you try to update the value of Lookup field which doesn't exist in the system or of other ids it will throw Invalid Id error.

Finally, according to your question, single field will serve your purpose.

  • You've misunderstood the question. I don't want it to throw an error. I need to be able to have the Lookup as an option and being able to enter new values as well May 10 '17 at 21:30
  • you can enter new values, so what's the issue May 10 '17 at 21:47
  • I've not being able to enter non existing values, I get Error: No matches found. May 10 '17 at 22:03
  • refer my answer, the lookup value should have valid id of the corresponding object May 10 '17 at 22:11

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.