I have designed a quick action lightning component to clone one of our [complex] custom objects.

The requirements are:

  1. Add a lookup field where the user would be able to choose another parent Opportunity for the cloned record.
  2. To have the ability to create a new Opportunity (if one doesnt exist) from within the lookup.

I ended up having to use a <force:inputField> to accomplish this.

similar to this example

The current issue (one of many) that I am facing is regarding the validation that this field is not blank. If the field is blank, I would like to show an error message similar to the other fields on the form. (see field in red below)

enter image description here

All my other input fields on the form use the lightning namespace. When the form is submitted, I validate the input as follows:

var allValid = component.find('fieldId').reduce(function (validSoFar, inputCmp) {
            return validSoFar && !inputCmp.get('v.validity').valueMissing;
        }, true);

this does not apply to my lookup field.

I have tried adding the attribute required="true" however this does not work, the user can submit the form successfully without filling it.

I use custom validation for that field by checking


however I cannot replicate the red border and error message to surround the Opportunity lookup field.

I have attempted setting the v.errors, or changing the v.validity but to no avail.

Has anyone experience a similar problem / Does anyone have any other suggestions?

Your Answer

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

Browse other questions tagged or ask your own question.