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"
        <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>
                <div aria-hidden="false" class="slds-section__content"></div>
        <lightning:layout multipleRows="true" horizontalAlign="spread" pullToBoundary="small">
            <lightning:layoutItem size="6" padding="horizontal-small">
                <lightning:inputField fieldName="Street_c"/>
 <lightning:layoutItem size="6" padding="horizontal-small">
                <lightning:inputField fieldName="CustomField__c"/>
        <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"/>
  • Please Post component code for quick answers
    – sdandamud1
    Jun 24 '19 at 12:47
  • can you get the full error infor from handleError event and post it here.
    – sdandamud1
    Jun 24 '19 at 13:46
  • I have fixed the issue, I have set the value of the checkbox field to false by default in doInit and I learned a new thing that we cannot save checkbox field as null into the database :) Thanks @Renji-xD Jun 24 '19 at 16:14

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

  • Added the code. I have already checked in the debug log and I only the above mentioned error and this might be a dumb question but do you think I would mandatorily pass the boolean value while saving the record cause that is not the requirement and I wonder why it's not complaining while I try to save the record in the standard layout. Jun 24 '19 at 13:00
  • With the base component - no it should be handled automatically. But try it manually (e. g. via execute anonymous apex) and create a record with null value for the checkbox - you should get the same error. Why its happening in your case is difficult to say - you can also check the request in the developer tools. There should be a callout named like 'aura.RecordUi.createRecord=1". Then check the form data section of the request to lookup what parameters were passed to the backend But at least it should be true that your error has nothing do it with required fields but invalid type
    – Renji-xD
    Jun 24 '19 at 13:20
  • Fixed. Thank you Jun 24 '19 at 15:58
  • 1
    cool - you may want to add a comment / add to your first post what was the issue in the end and how you fixed it so that other readers can benefit
    – Renji-xD
    Jun 24 '19 at 16:00

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.