I have a checkbox field which is unchecked by default. I am using this field in my lightning component where I am saving a record of my custom object along with other fields. I get error when I am trying to save this field even though this field is not required on the pagelayout. However this field works fine when I save the record by the standard 'new' button.
Error : 'CustomField__C: value not of required type:'
Does anybody have any pointers on this ?
Adding the code
<lightning:recordEditForm aura:id="neweditForm" objectApiName="Detail__c"
recordId="{!v.recordId}"
onsuccess="{!c.handleSuccess}"
onsubmit="{!c.submitForm}"
onerror="{!c.handleError}">
<lightning:inputField fieldName="Opportunity__c" value="{!v.oppRecordId}" class="slds-hide"/>
<div class="slds-section slds-is-open">
<h3 class="slds-section__title slds-theme_shade">
<span class="slds-truncate slds-p-horizontal_small" title="Section Title">Address</span>
</h3>
<div aria-hidden="false" class="slds-section__content"></div>
</div>
<lightning:layout multipleRows="true" horizontalAlign="spread" pullToBoundary="small">
<lightning:layoutItem size="6" padding="horizontal-small">
<lightning:inputField fieldName="Street_c"/>
</lightning:layoutItem>
<lightning:layoutItem size="6" padding="horizontal-small">
<lightning:inputField fieldName="CustomField__c"/>
</lightning:layoutItem>
<div class="modal-footer slds-modal__footer">
<lightning:button class="slds-button slds-button_neutral" type="button" variant="brand" label="cancel" onclick="{!c.cancel}"/>
<lightning:button class="slds-button slds-button_brand" type="submit" variant="brand" label="Save"/>
</div>
</lightning:recordEditForm>
Best Answer
Without any code my assumption would be that you are trying to save the record with null for the checkbox field which results to the mentioned Error.
I would recommend to check it via debug log or similiar and make sure that you are really passing a boolean value to save the record