christopheraucq

Update fields before Submitting

Blog Post created by christopheraucq Champion on Apr 24, 2015

When I was developing in Lotus Notes/Domino, we can use such events like QuerySave that allow us to run some code before saving and closing the form.

I thought it should be easy in Nintex Form to develop such a functionality.

After googling, it appears that you need to ise two buttons, the first one visible for the user with some Javascript code to update the field(s) ending by a btn.click() to fire the click event of an hidden Save and Submit Nintex button.

I have struggled with that solution because when I add the JavaScript code directly in the visible button, it, somehow, breaks the Nintex Form in O365. And even you want to change it back, for any reasons, the form seems corrupted.

So with the help of Davy Vlassenroot, I have added the Javascript code in the Form Settings and suddenly it worked ... until I realized that I have made a mistake by forgetting to select Javascript in the user button, it was still Save and Submit !!!

Good news: No need to use two buttons One is enough.

 

Update (2015/10/27)

If you need to update only one field, there is a standard feature.

In the Control Settings of the button, under Advanced, for Connected to,

you can select one field and fill the value returned: Completed

End of update (2015/10/27)

 

But if you need to update more than one fields, here is the complete solution for O365. I believe it should be the same for on-Premise.

Let's say we want to update to 'Completed' a drop down box containing Statuses.

 

1. In the Form Settings, add this Javascript function

function MyFunction()
{
  NWF$('#' + fldStatus).val("Completed").trigger('change');
}

Form Settings.PNG

2. where fldStatus is the value you need to put in Store Client ID in JavaScript variable of your Status field.

Store Client ID.jpg

 

3. In your Save and Submit button, note the Button action set to Save and Submit and not JavaScript.

Expand Advanced, and for Client Click, put MyFunction()

Control Settings.jpg

 

Once again, do not add directly your full JavaScript code in Client click but call a function instead.

 

"Make mistake but learn from them"

 

Happy Nintexing,

Christophe Raucq

Outcomes