Select randomly from excel columns

Goal
I created a survey form and i want a point when users successfully fill the form, they should receive free random code . I have the random codes in an excel sheet and I am using webhook to listen to the form submission.

I have successfully created and implemented a functioning form. The associated webhook has been configured to retrieve submitted data from the form. To ensure the uniqueness of the codes distributed, I have used the “Search Rows” module. Although my understanding of this module was uncertain, I have used it to search for existing rows and prevent duplicate codes from being assigned to users.

Form Submission From Webhook

Search Rows Module

Free code that will be distributed to the users when they complete the form submission.

I need help with how to randomly pick codes from the excel as shown in the screenshot and assign it to the user .

you could update a new column in your sheet that says wether the code is sent out already or not and for your new search module you filter only for the ones that have not been sent. that way you prevent sending duplicate codes

1 Like

Here are your options:

A. Generate code in scenario

Instead of pre-generating all the codes upfront, why not generate the code at the point of form submission, then check the spreadsheet if it has already been used, and if not, record it in the spreadsheet?

Generate your coupon code in a single step :+1:

Notes:

  • I used ABCDEFGHJKMNPQRSTUVWXYZ23456789!@#$%^& repeated 4 times to allow for repeated characters in the code, and to make it way less likely that a duplicate is generated. You can have more times but there are diminishing returns
  • I removed ambiguous characters 1ILO0
  • I used a triple shuffle - you could add more shuffles to randomise the array more but there are diminishing returns
  • I used substring 0;6, but you can change the 6 to however long you want your output to be

B. Use UUID

If you use UUID, you are guaranteed to never have a duplicate code

Then, you can reduce your scenario to only four modules

Screenshot_2024-01-24_100137

C. Find the next unused code

Instead of “select randomly”, you can also just use the next unused code

All you need is to have another column that lists the “used” status, so you can filter those rows out.

2 Likes

Very clever use of split(), shuffle() and join() to randomize a string by splitting a seed string into an array, randomizing the array and then reassembling it using join() with the emptystring as the delimiter. Well done!

2 Likes