Saving from OnClick Buttons doesnt work

Hello,

I've run into a small problem a couple of times and just wanted to ask why that is.

I have a couple of forms in which i use Buttons that should to certain OnClick Tasks.
For example:

This Button should change the Status from whatever it is, to "Delayed", which you can see in the second picture works just fine when clicking on it.

and this is the code on the button:

image

When the form closes after clicking on the Button it does not save the changed status and i have observed this now with every button that i made. When saving through a button onclick it never saves the changed values.

Hello @Dario_Chiga,

What SharePoint version are you using?

Please check if there are any errors in the browser console(F12) when you clicking the custom button. Share the screenshot.

I'm using SharePoint Online

Hello @Dario_Chiga,

I couldn't reproduce the issue on my form.

Please create a new list from scratch and design a simple form with a Title and custom button with the following code:

fd.field('Title').value = 'New Text';
return fd.save();

Is the value saved after submitting the form?

What version of the app package(v1.0.8) and the designer(v1.8.7) are you using?

To check the app package version, open the console (F12) go to Sources >> Page >> forms.plumsal.com
image

If the app package version is outdated, please follow the steps from the instructions to get the latest version:
Update the app package for Plumsail Forms (SharePoint Online) — SharePoint forms

I'm Using the newest Package available.
i have tried to do this on multiple forms with no result. new ones, existing ones. I can observe that onClick the Value changes but as soon as i save it, it doens't submit.

As you can see from my first post, when clicking the Value changes.
But on either a self-inserted button with the onClick Save or the default save button in the ribbon it doesn't save either way.

Hello @Dario_Chiga,

I'm sorry, I've missed the most important detail.

The field in read-only state can't be changed. To display the field value on the form and change the status on button click, you can:

  1. add the Status field to the form and hide it on form load using the code:
fd.spRendered(function(){
    $(fd.field('_Status').$parent.$el).hide()
});

That is required because the field must be present on the form in order to change its value.

  1. add the Plain Text control to display the status field value on the form. Like this:
    image
//field internal name in the square brackets  
Status [_Status]

Okay... This makes a lot of sense now and it worked perfectly.
Thank you very much for your support.
Fast and reliable as always!

1 Like