I suppose your custom script runs before new data (including the last action updates) is submited to the database (OnSubmit script is executed before the web form post).
I would suggest to try using SQL trigger on the table CL_CALL_LOGGING for updates (or CL_PROBLEM_HISTORY for inserts) to achieve your goals instead.
The only thing you have to check in the trigger - has the update (insert) been made by system or by officer. Unfortunately after a quick look at the call history table I couldn't find any column stating it very clearly (ACTION_TYPE can be used I guess).