1

I am getting this error when I try to use force:recordData to prefill a form. It does prefill the field, but I am unable to save.

Received unexpcted value during emit

Component:

<aura:component implements="force:lightningQuickActionWithoutHeader,flexipage:availableForRecordHome,force:hasRecordId" access="global" >
<aura:attribute name="recordId" type="Id"/>
<aura:attribute name="record" type="Object"/>
<aura:attribute name="CT" type="Asset"/>
<force:recordData aura:id="record"
                  layoutType="FULL"
                  recordId="{!v.recordId}"
                  targetRecord="{!v.record}"
                  targetFields ="{!v.CT}"
                  mode="VIEW"/>                                 

<lightning:card iconName="custom:custom18" title="New Monthly Follow Up">
    <lightning:recordEditForm objectApiName="ERIDT1__Forms_Documents_Evaluations__c"
                              recordTypeId="01261000000X0U2AAK">
        <lightning:messages aura:id="messages"/>
        <lightning:inputField fieldName="ERIDT1__Client_Tracker__c" value="{!v.recordId}"/>
        <lightning:inputField fieldName="ERIDT1__Dog__c" value="{!v.CT.ERIDT1__Dog__c}"/>
        <lightning:button class="slds-m-top_small slds-button slds-button_brand" type="submit" label="Save"/>
    </lightning:recordEditForm>
</lightning:card>

2

I recall that in my case the record saved despite that error. Could it be something unrelated then? Not sure if you are aware, but you can actually put the Save button outside the scope of lightning:recordEditForm like below and supplement the save action with other custom logic/error handling in your controller JS.

COMPONENT:

<lightning:recordEditForm aura:id="evaluationForm" objectApiName="ERIDT1__Forms_Documents_Evaluations__c"
                              recordTypeId="01261000000X0U2AAK">
        <lightning:messages aura:id="messages"/>
        <lightning:inputField fieldName="ERIDT1__Client_Tracker__c" value="{!v.recordId}"/>
        <lightning:inputField fieldName="ERIDT1__Dog__c" value="{!v.CT.ERIDT1__Dog__c}"/>
    </lightning:recordEditForm>
<lightning:button class="slds-m-top_small" variant="brand" type="button" name="update" label="update" onclick="{!c.saveRecord}" />

CONTROLLER JS:

saveRecord : function(component,event,helper) {
    try{
       component.find("evaluationForm").submit();
    }
    catch(err){
       console.log('-------> ERROR: ' + err + ' ** MESSAGE: ' + err.message + ' ** STACK: ' + err.stack);
    }
}
  • Thank you! This has fixed it and now saves the record. What's weird is I tried it w/o moving the button again and it created no records (the last record I created had an auto name # of 5244), so then I moved it back to where you had it and it worked again, but the auto number was 5247 as if it created 2 records, but they are nowhere. – Jennifer Jul 17 '18 at 2:29

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.