Eyedee.

Creating unique IDs with Zapier

If you're capturing information through a form and passing it into Zapier, it can sometime be handy to have a simple unique reference number.

Zapier has a number of hidden little tricks up its sleeve. Here’s one I discovered the other day when helping Art For Cure with their artist submissions.

The challenge

Art for Cure is a Suffolk-based charity who raise money for breast cancer research. Every year, the amazing team hold a large exhibition featuring artists from across the UK and totalling over 800 pieces of work. Curating and gathering the information from artists can be time-consuming and in the past they’ve had no real way to easily reference each piece of art across different spreadsheets, web links, emails and in-person conversations.

The solution

Zapier to the rescue! I worked with the Art for Cure team to create a new Master Google Sheet that captured information from a Typeform. In the middle sits a tidy little Zap that:

  • Processes the form information from Zapier into a Google Sheet
  • Creates a unique short reference number for the submission (code below)
  • Emails the artist with confirmation of the reference number
  • Emails the Art For Cure team to let them know there’s a new piece of art ready to review.

Now this is in place, everyone can use the simple reference number to know which piece of work needs addressing (lots of things can change in the run-up to the each exhibition; price, dimensions etc.)

The code

This is a pretty straightforward bit of code, but using Zapier’s built code block functions allows me to capture the unique ID from the Typeform submission, and add the artist’s initials to create a simple unique reference. At the end I’ve given the option to just return the artist initials and reference, or have the ability to append a three digit number at the end.

{
  // Get the Typeform ID, strip it down to x chars
  let ref_number = inputData.ref_number.slice(-5).toUpperCase();
  
  // Generate a random three digit number for the suffix
  var suffix = Math.floor(Math.random()*(999-100+1)+100);
  
  // Take the name from the Typeform submission, split it down to initials
  const ref_initials = inputData.ref_initials
   .split(" ")
   .map((word) => word && word[0].toUpperCase())
   .join("");
  
  // Create an artist reference
  var artist_reference = ref_initials + "-" + ref_number;
  
  // Add the suffix
  var artist_reference_suffix = artist_reference + "-" + suffix;
  
  // Return it as a usable value -  would look like JK-ADG3F-123
  return { artist_reference_suffix };
}

And that’s it! Pretty straightforward Javascript with the added power of Zapier.

Who wrote these words?

This post - Creating unique IDs with Zapier - was written by James Kindred, a freelance creative director and graphic designer based in Ipswich, Suffolk. He has 20 years of industry experience creating brands and creative strategies for clients and his own businesses.

If your business needs help with a project, whether it be planning or execution Get in touch.