You need to sign in to do that
Don't have an account?
Jennifer Munoz, ERI
Error when using force:recordData to prefill fields on lightning:recordEditForm
Hi,
I am getting the error "Received unexpected value during emit" when trying to prefill lighting:recordEditForm inputFields with data from force:recordData. The fields prefill, but I am unable to save the record. I was using this Trailhead as a reference: https://trailhead.salesforce.com/en/modules/lightning_data_service/units/lightning_data_service_manipulate_records
Code:
<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>
</aura:component>
I am getting the error "Received unexpected value during emit" when trying to prefill lighting:recordEditForm inputFields with data from force:recordData. The fields prefill, but I am unable to save the record. I was using this Trailhead as a reference: https://trailhead.salesforce.com/en/modules/lightning_data_service/units/lightning_data_service_manipulate_records
Code:
<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>
</aura:component>
Component:
...
<lightning:recordEditForm objectApiName="ERIDT1__Forms_Documents_Evaluations__c"
recordTypeId="01261000000X0U2AAK"
aura:id="evaluationForm"
onload="{!c.onLoad}">
<lightning:messages aura:id="messages" class="slds-hide"/>
<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:
({
onload : 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");
},
saveRecord : function(component,event,helper) {
component.find("evaluationForm").submit();
}
})
All Answers
Refer below link from StackExchange for similar discussion.
https://salesforce.stackexchange.com/questions/221690/lightningrecordeditform-received-unexpected-value-during-emit-error-on-loadin/221914
Please mark it as solved if my reply was helpful. It will make it available for other as the proper solution.
Best Regards
Sandhya
Component:
...
<lightning:recordEditForm objectApiName="ERIDT1__Forms_Documents_Evaluations__c"
recordTypeId="01261000000X0U2AAK"
aura:id="evaluationForm"
onload="{!c.onLoad}">
<lightning:messages aura:id="messages" class="slds-hide"/>
<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:
({
onload : 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");
},
saveRecord : function(component,event,helper) {
component.find("evaluationForm").submit();
}
})