I want to randomly assign a 4-digit ID to every respondent with no repeats. | XM Community
Solved

I want to randomly assign a 4-digit ID to every respondent with no repeats.

  • 11 November 2017
  • 4 replies
  • 72 views

Userlevel 4
  • Qualtrics Employee
  • 24 replies
I want to randomly assign a 4-digit ID to every respondent with no repeats (we anticipate ~500 responses). How could I set this up?
icon

Best answer by JulieT 14 November 2017, 18:23

View original

4 replies

Userlevel 5
Badge +10
Unfortunately, the random number generator ${rand://int/1000:9999} cannot guarantee no repeats. You'd have to set up a web service to a designated URL. (And your license would have to have API access) I've been searching for a Web Service to no avail. If anyone can suggest one, I'd appreciate it! So need this!
Userlevel 4
Badge +3
One thing I would use is a library that generates IDS. I have been using short-unique-id (https://www.npmjs.com/package/short-unique-id) for my surveys to put them in Batches.

I haven't thoroughly tested its abilities to create 100% unique ID's every time, and so I might look for a better library if you absolutely have to make sure they're unique. I trust it, but don't take my word for it.

This library is hosted via a pseudo CDN (Raw Git) so you can test it, but if you do use it, I would include the script in your project's code for safety.
Userlevel 7
Badge +7
A web service would be the best way to guarantee uniqueness.
Userlevel 4
Badge +3
In a past project, I knew of someone who used https://www.random.org/integer-sets/, which uses Atmospheric Noise to generate random numbers. It's way over the top, but I thought it was pretty cool!

Leave a Reply