0

I have a requirement where I need to submit a feedback I am having two fields: NAME, FEEDBACK I am using the record edit form in LWC and there are other fields for feedback which are lookup fields of the parent object(these fields were not mentioned in the record edit form) now my requirement is on clicking the submit feedback button, it need to submit values of lookup fields from background using onsubmit event in js function, as I am new to lightning web component , please help me how to set the values of feedback's look up field values.

thanks in advance

0

You can handle that the onsubmit event of the record-edit-form. HTML

<lightning-record-edit-form 
     record-id={recordId}
     object-api-name={objectApiName}
     onsubmit={handleSubmit}
     ...
>
     ...
</lightning-record-edit-form>

JS

handleSubmit(event){
   event.preventDefault();       // stop the form from submitting
   const fields = event.detail.fields;
   fields.Name = 'name';
   fields.Feedback__c = 'feedback';
   this.template.querySelector('lightning-record-edit-form').submit(fields);
}

See the document for more details

1
  • thanks for the solution – akhil Feb 17 at 12: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.