vanderLeest Posted January 21, 2019 Report Share Posted January 21, 2019 On submission of a file, I would like to store a time stamp and the current (authenticated / logged in) user. I found a javascript to store the time stamp and tried to add the user, but when I add the submitterId the script doesn't run: <script type="text/javascript">function addTimestamp (fileInputId, timestampInputId, submitterId) { var fileInput = document.getElementById(fileInputId); fileInput.addEventListener('change', function () { if (fileInput.files.length !== 0 ){ document.getElementById(timestampInputId).value = '[@cbTimestamp*]'; document.getElementById(submitterId).value = '[authfield:XC_ID]'; } }); }; addTimestamp('EditRecordMS_FSR_At', 'EditRecordMS_FSR_Dt', 'EditRecordMS_FSR_Subm'); addTimestamp('EditRecordMS_TPR_At', 'EditRecordMS_TPR_Dt', 'EditRecordMS_TPR_Subm'); addTimestamp('EditRecordMS_InvAt', 'EditRecordMS_InvDt, 'EditRecordMS_Inv_Subm'); </script> Any help sincerely appreciated. Do I have to split the script into two? Quote Link to comment Share on other sites More sharing options...
Kurumi Posted January 21, 2019 Report Share Posted January 21, 2019 Hi @vanderLeest, There's an easy way to store the timestamp using Submission Form. You could use this as a field in your table and set the Data type as Timestamp or you can configure this on your DataPage. You can check these articles for full documentation/tutorial.https://howto.caspio.com/tech-tips-and-articles/common-customizations/stamp-the-time-url-or-ip-address-to-new-and-updated-records/https://howto.caspio.com/tables-and-views/data-types/ I hope this helps! Quote Link to comment Share on other sites More sharing options...
vanderLeest Posted January 22, 2019 Author Report Share Posted January 22, 2019 Thanks Meekee, for the tip I do know how to store a timestamp on a submission and update/report form, which will be a timestamp for the record, (which an also be done on a table) The Report Datapage I hope to create allows two different users to store 3 separate files (reports), and I want to store who uploaded each file and when, by autofilling the submitter's user ID and a timestamp . Floris Quote Link to comment Share on other sites More sharing options...
Vitalikssssss Posted January 22, 2019 Report Share Posted January 22, 2019 Hi @vanderLeest, I do not think that you need to use a JS code to achieve the desired workflow. You can make fields "User ID" and field for a timestamp hidden and receive the desired parameter upon record submit. Hope this helps. regards, vitalikssssss Quote Link to comment Share on other sites More sharing options...
vanderLeest Posted January 22, 2019 Author Report Share Posted January 22, 2019 This maybe not the most elegant solution, but splitting the script into two functions does the trick: <script type="text/javascript"> function addTimestamp (fileInputId, timestampInputId) { var fileInput = document.getElementById(fileInputId); fileInput.addEventListener('change', function () { if (fileInput.files.length !== 0 ){ document.getElementById(timestampInputId).value = '[@cbTimestamp]'; } }); }; addTimestamp('EditRecordMS_FSR_At', 'EditRecordMS_FSR_Dt'); addTimestamp('EditRecordMS_TPR_At', 'EditRecordMS_TPR_Dt'); addTimestamp('EditRecordMS_Inv_At', 'EditRecordMS_Inv_Dt'); function addSubmitter (fileInputId, SubmitterId) { var fileInput = document.getElementById(fileInputId); fileInput.addEventListener('change', function () { if (fileInput.files.length !== 0 ){ document.getElementById(SubmitterId).value = '[@authfield:XC_ID]'; } }); }; addSubmitter('EditRecordMS_FSR_At', 'EditRecordMS_FSR_Subm'); addSubmitter('EditRecordMS_TPR_At', 'EditRecordMS_TPR_Subm'); addSubmitter('EditRecordMS_Inv_At', 'EditRecordMS_Inv_Subm'); </script> 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.