Page 1 of 1

Button for changing a field's value, save and close the form

Posted: 05 Dec 2019
by Leslie
Hello !

I have an issue form, and I want to add a button "Close the case", a button that changes the value of the "Status" field, do some other things, saves and closes the form.

I added a button, added this code in OnClick :
fd.field('Status').value('RĂ©solu');
fd.save().click();

But it doesn't work.
It sets the status value well, and refreshes the form.
But :
_ The form is still open.
_ And if I close the form (just close, with the little red cross in the top right corner of the form box), it appears the Status field's value is always the previous value ! So the submission doesn't work.

Can you help me ?

Thank you in advance !

Re: Button for changing a field's value, save and close the form

Posted: 06 Dec 2019
by mnikitina
Hello Leslie,

You need to add a custom button in the form and then add your code in the OnClick property of the button.
button.PNG
button.PNG (6.93 KiB) Viewed 3646 times
Then it should work.

Otherwise, please check if there any errors in the console (F12) and share the screenshot so I could troubleshoot the issue.

Re: Button for changing a field's value, save and close the form

Posted: 28 Feb 2020
by Leslie
Solved !

It was because the Statuts field was in readonly. (in another function of the JS to "protect" the Status field, with fd.field('Status').readonly(true);)
Without the readonly, the field can be changed et saved.

I don't know if it's normal or not, but it works.

Re: Button for changing a field's value, save and close the form

Posted: 02 Mar 2020
by mnikitina
Hello Leslie,

Yes, the field should be enabled so you could change and save values. That is the expected behavior.