Let's say I have a Lightning Web Component which looks like this:
<template>
<lightning-record-edit-form object-api-name="Opportunity" onsuccess={handleSuccess}>
<lightning-messages></lightning-messages>
...
</lightning-record-edit-form>
</template>
If an apex exception occurs, I get an error message displayed like this:
How do I clear this message from the UI?
I have tried <lightning-messages closable="true">
and that does not seem to work.
Any thoughts?
Best Answer
Okay, to solve this problem I used a combination of lightning-record-edit-form and lightning-record-view-form and I just omitted the lightning-messages tag. I used a js variable called "editMode" to conditionally render lightning-input-field vs lightning-output-field. Then, I use handleError() onerror to parse the error message and display a closable error toast to the user.
Here is js controller:
@track editMode;