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

  • 0
    Certified Lead Developer

    AFAIK, there is no supported way of doing this. What is the use case?

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

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

  • 0
    Certified Lead Developer

    AFAIK, This is not possible without any user click. Workaround: You can save users last input value through a click using a!writeToDataStoreEntity inside saveInto. but this can also be achieved by Save Draft option as well. So, auto save is not a feature of Appian till date.

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

  • It is possible to configure a user input task to have an exception timer event. If an assigned task is not completed in time then the exception flow is triggered.

  • 0
    Certified Associate Developer

    Hi All,

    As part of our POC, we are calling web API on refresh variable of the site page. The web API is responsible to save data to DB. This API gets triggered at an interval and saves the data. I would like to know if this would be a best approach to achieve auto save function or not .

    Thanks!

    Mayur Mondhe 

  • 0
    Certified Lead Developer
    in reply to mayurm0002

    I consider this a bad practice!

    But instead of discussing how to solve that, I would be more interested in the actual requirement? Why do you think this is necessary? What is the benefit?

  • I refer to my previous response. Whilst this is certainly less "chatty" than updating on every user event, whatever data the user has entered in any/all fields that you are sending will include values that might be considered to be invalid by any validation errors thrown on any input fields.