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

Discussions about Forms Designer for SharePoint 2013 / 2016 and Office 365.
Locked
Leslie
Posts: 32
Joined: Thu Dec 05, 2019

05 Dec 2019

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 !

User avatar
mnikitina
Posts: 264
Joined: Wed Jun 05, 2019

06 Dec 2019

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 2049 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.

Leslie
Posts: 32
Joined: Thu Dec 05, 2019

28 Feb 2020

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.

User avatar
mnikitina
Posts: 264
Joined: Wed Jun 05, 2019

02 Mar 2020

Hello Leslie,

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

Locked
  • Information
  • Who is online

    Users browsing this forum: No registered users and 20 guests