Assigning unique coupon codes to records

Dear community, someone asked a similar question but the topic has been archived with no replies.

My problem is that I have made a table with 10K records made of 4 letters coupons (promo codes) in the primary field. Another column is made of emails linked to another table with my users (Master table). I’d need for unused coupons/records to be picked and assigned to one user each time they join us with a certain status.

I am wondering if I would need an automation (from Zapier or Airtable) or a script to achieve this.

Thanks in advance!

Hi @Sophie_Mona_Pages ,

It’s a bit of a hack, but I have a similar kind of workflow and this is how I deal with it.

  1. Create a column in your coupon code base with a formula that just has the string “Coupon Code” inside it (yes include the quotes in the formula field). This should result in every cell in this column displaying the the text “Coupon Code”. Call this column “Zapier Search Column”

  2. Create a view in your coupon code table that is filtered so that the link column connected to your users table “does not exist” or “is empty” (i don’t remember the verbiage right now). Name this view “Available Coupon Codes”

  3. Create a zapier with the following steps:

    • Zap Step 1: Zapier looks for newly added user record (or new record in view)

    • Zap Step 2: Zapier searches “Available Coupon Code” View using the “Zapier Search Column” Column.

      • Your Search text should be “Coupon Code” (to match the formula you created in the airtable column).

      • NOTE: When you test this step you are only going to get a single result even though technically everything in the view matches your search – this is because zapier is not smart enough to return multiple results and basically displays the first match it finds. Because your entire view is filtered so that any of your used coupons will not show up, whatever coupon record the search does return won’t conflict with any previously assigned coupons.

    • Zap Step 3: Edit the record from the first step. Put the record ID found in the search step (for the coupon) as the input of the field which is linking your User Table to your Coupon Table.
      This basically create

      • This will assign the found coupon to your new user and simultaneously filter the used coupon code out of the “available” view taking it out of circulation when users are being added in the future.

Wrote this up super quickly so, let me know if you have any questions!

1 Like

Thanks a lot Adrian! That’s super helpful :slight_smile: