I'm trying to update a checkbox field via javascript before the submit. I'm getting correctly the lightning input field (I can see in the console) but is not getting saved. I also tried with a text field and it's working fine.
handleSubmit(event){
event.preventDefault();
const fields = event.detail.fields;
fields.isSign__c = true;
fields.Customer_Name__c = 'John Adams';
console.log('fields: ' + JSON.stringify(event.detail.fields));
this.template.querySelector('lightning-record-edit-form').submit(fields);
[...]
In the html file I have this for the checkbox (I'm don't want to show the field, it's going to be hide) but I would like to update with the submit.
<lightning-record-edit-form record-id={recordId} object-api-name="CustomObject__c" onsubmit={handleSubmit}>
<lightning-input-field field-name="isSign__c"> </lightning-input-field>
[...]
Thanks in advance.
I tried with other fields and it worked but with the checkbox seems that somethins doesn't like it and I don't know why
isSign__cis the exact field name? is your user allowed to edit the field (profile/permission sets). Do you have any triggers, workflows etc that might be setting the value back to false? Check debug log maybe?