Rmorr Posted August 30, 2017 Report Share Posted August 30, 2017 Hello! This might be an unusual request, but I am looking for a way to create and stamp a new submission ID on multiple records each time a bulk edit is submitted for a particular DataPage. The ID needs to be unique to other IDs, but it will be stamped on multiple records in the table at the point of submission. My thought was to create a hidden field with a default value, which would be a combination of a prefix (i.e., WO-) and then a system parameter (i.e., [@cbTimestamp]). The problem I'm running into is that I would like the date to be broken down into a numeric string instead of having spaces and punctuation, such as dashes and colons. This is what I'm currently getting: WO-08/30/2017 11:34:46. I would like to get this instead: WO-1504110886. Any ideas on this? I very well may be overthinking things, so I welcome suggestions. We don't have to use the timestamp at all, but it was just an idea for how to create a unique ID at the point of submission. Quote Link to comment Share on other sites More sharing options...
Vitalikssssss Posted August 31, 2017 Report Share Posted August 31, 2017 Hello Rmorr, I would suggest using Short date format for timestamp which has reference name [@cbTimestamp*]. You can utilize Javascript function named replace in order to remove forward slashes from timestamp parameter. Hope this helps. Quote Link to comment Share on other sites More sharing options...
Rmorr Posted August 31, 2017 Author Report Share Posted August 31, 2017 Thank you for the quick feedback! The problem I'm running up against is that the short date is not detailed enough to distinguish it from other submissions. For example, we may have multiple users submitting entries close to the same time in any given day, and I need a way to make the submission ID unique. I was thinking the long date format (including seconds) might come in handy for that, but I'm not having success yet with the replace function. User error I'm sure! Do you have any other suggestions along the lines of creating unique IDs (preferably with a prefix) at the point of submission? I thought about creating a separate table just for the purpose of generating unique IDs, but I haven't worked through the details yet on how to issue one ID per submission and not reuse it. My submission table needs to allow for that unique ID to be stamped on multiple items with the submission. Hope that makes sense! Quote Link to comment Share on other sites More sharing options...
Vitalikssssss Posted September 8, 2017 Report Share Posted September 8, 2017 Hi Rmorr, I have created following Javascript which will replace unnecessary elements from Timestamp value and concatenate modified value with a predefined prefix "WO-". You should have a Virtual field which will receive Timestamp parameter on page load. <script> function Replace(){ var a = document.getElementById("cbParamVirtual1").value; document.getElementById("InsertRecord_____Yourfield").value='WO-'+a.replace(/\/|:|\s+/g, ''); } document.getElementById("caspioform").onsubmit=Replace; </script> Please paste this script into Footer of your Submission Form. Hope this helps. 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.