Forum Discussion
We do something similar to what tristaanogre does. We have a variable called idstring that is a combination of date, hour, minute, second and if I need a random string for any field then I use eval(idstring) to get it.
DOH! Now why didn't I think of that, Marsha_R.
So... now I'm going to go back to my project, create a property in my framework script extension for that SS# and have it just simply return that unique ID. I've been doing the dumb thing and creating the string each time rather than from a centralized point... I feel sheepish. :)
I'll probably also add another property that will return a more lengthy unique ID for other use similar to what you've done. Thanks for the inspiration!
- tristaanogre7 years agoEsteemed Contributor
Threw this together quick... JScript/JavaScript compatible. If you are using keyword tests, call this script routine and then you can use "Last Operation Result" in either a variable assignment or a parameter to utilize it in other operations.
function getUniqueID(digitLength) { var JJJHHMM = 7; var JJJYYHHMM = 9; var MMDDYYHHMM = 10; var MMDDYYYYHHMM = 12; var MMDDYYYYHHMMSS = 14; try { switch (digitLength) { case JJJHHMM: return aqConvert.DateTimeToFormatStr(aqDateTime.Now(), '%j%H%M'); break; case JJJYYHHMM: return aqConvert.DateTimeToFormatStr(aqDateTime.Now(), '%j%y%H%M'); break; case MMDDYYHHMM: return aqConvert.DateTimeToFormatStr(aqDateTime.Now(), '%m%d%y%H%M'); break; case MMDDYYYYHHMM: return aqConvert.DateTimeToFormatStr(aqDateTime.Now(), '%m%d%Y%H%M'); break; case MMDDYYYYHHMMSS: return aqConvert.DateTimeToFormatStr(aqDateTime.Now(), '%m%d%Y%H%M%S'); break; default: throw Error('An unknown digitLength was used. Please use a value of 7, 9, 10, 12, or 14'); } } catch (exception) { Log.Error(exception.message, exception.stack); return 'error'; } }
I'm also going to incorporate this into the OgreUtilities script extension.
- Marsha_R7 years agoChampion Level 3
I'm just lazy. I got tired of cutting and pasting it for every place I needed a number. :)
- RichBopp7 years agoContributor
Gang,
Thank you so much for all of the suggestions. I'm neck deep in a testing cycle right now, but will get back to trying all this out by the end of this week.
Kudos to All,
Rich
Related Content
- 2 years agovericomms
- 12 months agoTauras
- 11 months agosinis
- 3 years agogeneticmaterial
Recent Discussions
- 2 days agovladd1