We have a requirement that when clicking a link, will start file download, at the meantime, we need to do some data update.
Can anyone advice how to achieve this?
Discussion posts and replies are publicly visible
So not exactly as you describe. But you could run a process that sends the file to an email address and then does the data update.
Why are the two requirements linked? What is it about the file download that is inextricably linked with the need to update some data?
we want to record user download action, change the status in DB accordingly
Download action is already logged in the logs. Where are you intending using this information? Who needs to see it? When? Why?
The business user want to see the status, to make it more which files have been downloaded in the list
If they only want to see if a document has been downloaded you could use the fn!getdownloadersfromgroup().
If the file hasn't been downloaded the result will be empty, otherwise it'll return the list of users who have downloaded the file. Strongly recommend you provide the narrowest-scoped group to this function (rather than, say, 'All Users' which is the whole list of Users in your environment).
Any potential solution for this (using reasonable OOB functionality) will require 2 clicks, as far as I can tell.
In the simplest example I can think of, the user could be required to click an initial link/button to enable downloading (this would be able to execute arbitrary code to do DB updates / etc), then only after they've clicked that for a given file / group of files perhaps, the download link(s) become active.