Have you ever found yourself overwhelmed while trying to add a round-robin to your Zapier workflow? In a previous post, I discussed a method that required three tasks per cycle.
But what if you could achieve the same result with just one task? That’s right, one task for the same outcome.
Ready to streamline your workflow?
Let’s dive in!
Ensuring Security
Before we jump into the setup, let’s address security. It's crucial to keep your stored information in Zapier secure. We'll generate a unique, nearly unguessable 'password' for the Storage by Zapier step using a UUID (version 4).
How to do it:
Generate a UUID: Visit a UUID generator to create a version 4 UUID. This string will act as your secure 'password' for your storage connection.
Set Up Your Storage: Navigate to Zapier's Storage Connection page. Add a new connection, and when prompted, paste in the UUID you generated and confirm.
Using a UUID enhances security, ensuring your stored data remains protected.

Set Up Your Storage: Now, navigate to Zapier's Storage Connection page. Add a new connection and when prompted, paste in the UUID you generated and confirm.

Step-by-Step Guide:
Add Code by Zapier: In your existing Zap, add a new step and choose 'Code by Zapier'. Then, pick the 'Run JavaScript' action.
Fill in Input Data:
Name the first row 'array' and map or select a list for its input.
Name the second row 'secret' and paste the UUID you generated earlier into this row.
Input the Code: Paste the provided JavaScript code for the round-robin in the 'Code' field.
By following these steps, you’re not only adding a round-robin to your Zap, but you’re doing it securely and efficiently!

Here’s the code to copy/paste:
// Define the array of loopconst loop = inputData.array.split(","); // Create a function to cycle through the array function cycleArray(arr, currentIndex) { // Create a function to return the next index function nextIndex() { // Increment the current index currentIndex++; // If the current index is >= to the length of the array, reset to 0 if (currentIndex >= arr.length) { currentIndex = 0; } // Return the current index return currentIndex; } // Return the function return nextIndex; } // Store the current index in Storage by Zapierconst secret = inputData.secret;const store = StoreClient(secret); store.get('myKeyHere') .then(currentIndex => { // If the current index is not found in Storage by Zapier, start at 0 if (!currentIndex) { currentIndex = 0; } // Create a new function to cycle through the array const cycle = cycleArray(loop, currentIndex); // Call the function to get the next index const nextIndex = cycle(); // Store the next index in Storage by Zapier return store.set('myKeyHere', nextIndex) .then(() => { // Return the next value as the result return { result: loop[nextIndex], current_index: nextIndex }; }); }).then(result => { callback(null, result); }).catch(error => { console.error(error); callback(error); })
Time to Test:
Hit 'Test' to run this new Code by Zapier action. If all goes well, you'll successfully cycle through your list of values using just one task.
When Going Live:
Once satisfied with the test, publish your Zap. The beauty of this setup is your round-robin will resume from where it left last, ensuring smooth operation.
Congratulations! You've just simplified your Zapier workflow by adding a secure, efficient round-robin—in just one task! Impressive, isn’t it? If you have any questions or face any hurdles, feel free to drop a comment below. I’m here to help!
Wishing you a productive day ahead!
Comments