4

I have one Lightning component with lightning:recordEditForm. Some times this is throwing an error "Received unexpected value during emit".If i refresh it sometimes it is not showing any error.It is used in Lightning quick action.

Error of Lightning record edit form on initialization

  • Is this from code you've written, or a standard quick action? – sfdcfox Jun 15 '18 at 18:30
  • Yes @sfdcfox. I placed my component in Quick action – sfdcYodha Jun 15 '18 at 18:56
  • This Quick action calling my Custom lighting component. I am loading Lighting:recordEditform in that component with predefined some the fields. This form is related to Opportunity object – sfdcYodha Jun 15 '18 at 18:57
  • I also suffer from this error. Probably has a relation with Summer'18 release. Mine is placed right onto Lightning page. I haven't found the chance to debug it yet. I'll share the debug results when I finish it here. – TSunar Jun 18 '18 at 5:55
  • @TSunar. Yes it is look like that. Not only my single component wherever i used Lighting:recordEditFrom it is throwing this error randomly on initialization. Please let me know your thoughts on this. – sfdcYodha Jun 18 '18 at 13:11
4

I have also been suffering form this issue. I use a lightning.recordEditForm component with some visible and some hidden lightning:inputField elements inside it, to create a clone Quote record inside a Quote record.

My debug findings:

  1. This is the JSON that onerror event returns from server for this error:

{"error":{"statusCode":400,"errorCode":"SERVICE_EXCEPTION","message":"Received unexpected value during emit"}}

  1. I was able to isolate the lightning:inputField elements that cause the error: standard OpportunityId field and custom Quote lookup field in Quote object. These two fields are pre-populated and hidden in my form - removing value attributes from both stopped the error. However, pre-population values are perfectly valid.
  2. In Chrome console log, aura framework throws some complex error logs. I couldn't analyze them.

In the end, I concluded that this is a platform bug which was brought in with Summer '18 release and came up with a functonal workaround - hiding lightning:messages component when this specific error occurs.

Workaround

Workaround I applied basically keeps lightning:messages component hidden whenever the occurred error JSON includes this specific error message in it. Note that this solution is aimed at the error happening during component initialization.

Component code

<lightning:recordEditForm objectApiName="Quote" onerror="{!c.showMessages}">
    <lightning:messages aura:id="messages" class="slds-hide"/>
</lightning:recordEditForm>

Controller code

showMessages : function (component, event, helper) {
        var errorParamsRaw = event.getParams();
        var errorParamsJSON = JSON.stringify(errorParamsRaw);
        console.log(errorParamsJSON);
        if (!errorParamsJSON.includes("Received unexpected value during emit"))
            $A.util.removeClass(component.find("messages"), "slds-hide");
    }

As the next step, I'll probably create a new known issue topic regarding this issue.

  • Thank you @TSunar. is there any known issue tied to this one "In the end, I concluded that this is a platform bug which was brought in with Summer '18 release and came up with a functonal workaround - hiding lightning:messages component when this specific error occurs." It is working in some situations great but some times it is not allowing user to save the form. – sfdcYodha Jun 20 '18 at 12:09
  • Your workaround only suppresses the message on a UI. I created a generic component that uses lightning:recordEditForm and toggles between lightning:inputField and lightning:outputField based on a 'Edit/View' button click. When I put 4 instances of the same component in one page, the fields DISAPPEAR on click throwing this error in console: bB {component: "lightning:recordEditForm", componentStack: "[lightning:recordEditForm] > [lightning:recordEditForm]", action: null, name: "AuraFriendlyError", message: "Error in fetching record or record metadata. [Received unexpected value during emit]", …} – Lightning Evangelist Jul 5 '18 at 13:42
  • @sfdcYodha, workaround is working fine at my side.I haven't encountered or got informed about inability to save the form. I, unfortunately, haven't done any work about known issues, since this is quite low prio in my backlog. – TSunar Jul 6 '18 at 5:19
  • @Kal, my workaround exactly does that. I only want to suppress that unidentified error message, and keep other functionality still. On the other hand, if I'm not mistaken, your component could easily be constructed by standard component lightning:recordForm which became GA in Summer'18. – TSunar Jul 6 '18 at 5:22

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.