Jump to content

Timestamp as numeric string


Recommended Posts

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.

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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.   

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...