0

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

4
  • JavaScript is case-sensitive, are you sure isSign__c is 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? Commented Nov 15, 2022 at 1:27
  • Hi, thank you for the response. Yes, the field name is IsSign__c. I'm testing it with the System administrator so yes, it has the permissions (I had checked also). There is no trigger, just a flow but does nothing with this field. I have checked the console log, and it seems that the value is getting ok, but when the submit is done, the value does not change. Commented Nov 16, 2022 at 7:12
  • Might be uppercase vs lowercase "i", JavaScript is case-sensitive. Commented Nov 16, 2022 at 8:35
  • 1
    You were totally right I didn't see it!! Thank you! Commented Nov 17, 2022 at 8:27

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.