Auto save data from site page to DB

Certified Associate Developer

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

Parents
  • 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.

Reply
  • 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.

Children
  • 0
    Certified Lead Developer
    in reply to ajhick

    a!startProcess works only inside a saveInto which reacts on use input only. Same for a!writeToDataStoreEntity().

  • Yes, totally understand this and wasn't suggesting it could work without user input. But if the use case is to know when someone goes to a site, starts entering details and then stops and doesn't submit then a!startProcess and a!writeToDataStoreEntity would work. Obviously this doesn't help if you need to know the moment they go to the site (what if they load the site and goes to lunch and only enters the first details when they return?) or if you need to know when the site is visited and no details are entered. Like in your response we'd need to know the exact use case to know suggest anything further.

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