vanderLeest Posted March 9, 2020 Report Share Posted March 9, 2020 I want to set a Comment Date field to the current date time, when the associated Comment has been entered and/or updated on a Details Page of a Search and Report DataPage. From code found in previous topics, I constructed the following JS script, but sadly it is not working. Any help will sincerely be appreciated (as updating the field via a Table Trigger creates too many cascading actions). PS On the Stack Overflow site, I picked up the suggestion to add an eventlistener statement MS_FSR_Comment is a TEXT (255) field with Text Area on the Details page MS_FSR_CommDt is a Date/Time field <script> document.getElementById("EditRecordMS_FSR_Comment").addEventListener("change", function(){ SetFSRDate; }); Function SetFSRDate(){ var entered = document.getElementById("EditRecordMS_FSR_Comment").value; if (entered.length > 0) { var currentdate = new Date(); var datetime = currentdate.getDate() + "/" + (currentdate.getMonth()+1) + "/" + currentdate.getFullYear() + " " + currentdate.getHours() + ":" + currentdate.getMinutes() + ":" + currentdate.getSeconds(); document.getElementById('MS_FSR_CommDt').value = datetime; } } </script> Quote Link to comment Share on other sites More sharing options...
vanderLeest Posted March 9, 2020 Author Report Share Posted March 9, 2020 I noticed one error in the script above: the field in the last line before </script> should be referenced as document.getElementById("EditRecordMS_FSR_CommDt").value = datetime; Even with this correction, the MS_FSR_CommDt is not updated Quote Link to comment Share on other sites More sharing options...
vanderLeest Posted March 10, 2020 Author Report Share Posted March 10, 2020 I'm happy to answer my own topic. the following script works: document.getElementById("EditRecordMS_FSR_Comment").onchange = function(){ var entered = document.getElementById("EditRecordMS_FSR_Comment").value; if (entered.length > 0) { var currentdate = new Date(); var datetime = currentdate.getDate() + "/" + (currentdate.getMonth()+1) + "/" + currentdate.getFullYear() + " " + currentdate.getHours() + ":" + currentdate.getMinutes() + ":" + currentdate.getSeconds(); document.getElementById("EditRecordMS_FSR_CommDt").value = datetime; } }; And don't forget to set the receiving field to a Text field on the Report Details Page. (if set as Display Only it cannot be updated) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.