I would suggest to write only on OnSave so whenever any user change or create new record automatically got updated. For existing record: I would suggest to update Database table directly. Note: If any other third party application try to create / update existing record javascript will not execute. If you need ultimate solution then I would suggest to write simple workflow (asych action) or plugin (for immediate action) Please mark suggested answer if it helps.
↧