Hi All,
We have a requirement where we need to automatically save data to DB from site page if user is not performing any action for defined time.Please make a note that we looking for a solution which would save data without any user interaction.Any help is highly appreciated.
Thanks!Mayur Mondhe
Discussion posts and replies are publicly visible
The only thing I can think of is to have either a!writeToDataStoreEntity() or a!startProcess() configured into every single saveInto of every single component that a user could fill in on the site. This is cumbersome and a bit messy but you could get it to know everything a user input. Especially using a!startProcess() you could configure something to happen after a certain amount of time after the first input was received.
I've never had to do something like this but you would have to be careful of the refreshAfter variable (where available). If there's a large text input and someone never unfocuses this solution wouldn't capture that unless refreshAfter was "KEYPRESS". I've never tested anything like this so this suggestion is only an idea.
I had a play with the new a!executeStoredProcedureOnSave() that comes with 22.1 but the pattern remains the same - you have to trigger this in a saveInto on an input component which, in turn, is triggered by a user event. There is no method to trigger this in a refreshVariable with a refreshInterval which is what would be required to implement what in effect would be the equivalent of an autosave that you might find in, say, MS Word.
CAUTION: Adding such a function to every saveInto of every input component would have the effect of writing to the DB on every saveInto which, btw, includes every keystroke if refreshAfter is set to "KEYPRESS". Not only that (it gets worse!) if you have validations on the input field then these happen AFTER the saveInto event, so you'll have invalid data written to the database.
It's also very "chatty" and probably wouldn't scale well with an application/environment that had lots of applications with lots of users with very forms-intensive implementations.