Commit value numeric text field in flex repeater before saving

Hi,

I have a flex repeater which is showing a flex with a numeric text field in it.
The parameters of the flex are in and output parameters and are connected to the numeric text field bidirectional.
Below the flex repeater, there is a save button which gets the info out of the flex repeater and saves it in a database.
This works but when you fill in the last flex and press the save button the last value is not saved because it’s not committed.
You need to press enter and push the save button afterward.
Is there a way I can commit the value when the save button is pushed?

Try the “Commit On Focus Loss” property on the numeric text input field in your template.

Edit: Hmm. flex repeater, not template repeater. Sigh. Mondays. /:

1 Like

It’s not immediately clear how your save button gets the info out of the flex repeater, but a simple setup (see included View) displays that the value of the NEF is committed when focus is lost, and any scripts should pick up that committed value. There’s a possibility that the chain of events in your View is completed before this commit takes place, but I would need to see the View in question to tell you for sure.
view.json (1.8 KB)

The script of the save button:

GasMeasurementID = self.view.params.ID
Methane = self.getSibling("FlexRepeater").props.instances[0].Measurement
CarbonDioxide = self.getSibling("FlexRepeater").props.instances[1].Measurement
Oxygen = self.getSibling("FlexRepeater").props.instances[2].Measurement
HydrogenSulfide = self.getSibling("FlexRepeater").props.instances[3].Measurement
Valid = 1
ErrorStr = "<HTML>"

system.db.runPrepUpdate("UPDATE GasMeasurement SET Methane = ?, CarbonDioxide = ?, Oxygen = ?, HydrogenSulfide = ? WHERE GasMeasurementID = ?",[Methane, CarbonDioxide, Oxygen, HydrogenSulfide, GasMeasurementID])

I added a export of the template and the popup with the issue.
Export.zip (11.8 KB)

@pturmel i was looking for a property like that but i could not find it.

I attempted to replicate you issue with the provided View but was unable. During my attempts I found that Clicking the save button removed the focus from the final Numeric Entry Field (blur), which commits the value contained within. Once the onClick Event occurs for the button, all values from the Flex Repeater are in place.

My Steps:
I replaced your query binding (more on that in a minute) with hard-coded values since I needed to attempt to mock your data - and set the values to different increasing integers (1,2,3,4).
I replaced the actual query line in the submit button with some logging:

system.util.getLogger('RESULT').info('CH4: {0}, CO2: {1}, O: {2}, H2S: {3}, ViewIDParam: {4}'.format(Methane, CarbonDioxide, Oxygen, HydrogenSulfide, GasMeasurementID))

Once I put the Designer into preview mode, I incremented each of the NEFs (to 2,3,4,5) without clicking Enter after any of them, and then clicked save.
This was my logged result: CH4: 2, CO2: 3, O: 4, H2S: 5, ViewIDParam: 1

A set of steps you could try to help you troubleshoot on your end is to place a line of logging into a Property Change Script for FlexRepeater.props.instances[3].Measurement which logs currentValue.value, as well as a line of logging in the click event of the save button which logs that the button was clicked. Introducing these lines during my testing allowed me to verify the value of the NEF was being written before the script was executed.

Side note:
I noticed you have two script Actions for the Save Button. While this is allowed, please realize that there is no guarantee of the order in which those script actions will be run; you could very possibly find your popup closed before the saving script completes. If there is ANY requirement that one of those scripts completes before the other, you must combine them into the same script or find a different way to perform the same logic.

Hi,

You need to test this issue on a ipad and not in de designer or webbrowser becuase this will not cause the error.