Skip to main content

Hello!

 

I currently am running into an issue in my email parsing zap. The part that is causing issues isn’t due to the parsing however. At some point I try and create a new employee ID based on three criteria:
1. The letter “A”
2. The date they started “072125”
3. A three digit number starting with “001”

So their id if they began today would be “A072125001”, the second person run would be “A072125002” and so and so forth.

 

It works fine when I run it the first time. However, on the next set of data, it does not properly update to “...002” and still tries to create “...001” even though it’s been used.

I’m unsure where I have gone wrong, but here are the relevant steps shown in detail:

 

const used = inputData.used ? inputData.used.split(',').map(Number) : [];
let nextNum = null;

for (let i = 1; i <= 999; i++) {
if (!used.includes(i)) {
nextNum = i;
break;
}
}

if (nextNum === null) {
throw new Error("All 3-digit numbers used for today!");
}

const padded = String(nextNum).padStart(3, '0');
const finalId = `A${inputData.today}${padded}`;
const updatedUsed = [...used, nextNum].join(',');

return {
finalId,
updatedUsed,
storageKey: `used_${inputData.today}`
};

and finally:

 

If you could point me in the right direction on what to fix, I would greatly appreciate it. Is it the key that is the issue?

 

Thanks for your help!
 

Hi ​@codemonkeylikesfritos 

You likely do NOT need to use a Code step.

TIP: Formatter steps and some other native Zap apps count as 0 Tasks in Zap Runs: 

 

Instead, try these Zap action steps:

  • Action: Formatter > Date & Time > Format
    • Format: MMDDYY
  • Action: Storage - Increment Value
    • Key: Counter
    • Increment by: 1
  • Action: Formatter - Text - Length
    • Count the length of the returned
  • Action: Formatter - Utilities - Lookup Table
    • See screenshot below for concept
    • Lookup the output of the previous Formatter step (Length)
    • Returns the formatted value with leading 0s
    • Config
      • 1 | 00[STORAGE KEY VALUE]
      • 2 | 0[STORAGE KEY VALUE]
      • 3 | [STORAGE KEY VALUE]

 

Those steps will give you the 3 individual data points you need to then concatenate those variables in a Zap step field.

 

Configure another Zap that runs on a daily schedule to reset the Storage Key Value to 0.

  1. Trigger: Schedule - Daily
    1. Run at midnight
  2. Action: Storage - Set Value
    1. Key: Counter
    2. Set to 0

 

You can use Paths/Filters if you want to handle counts over a certain limit:

https://zapier.com/apps/paths/integrations#help

https://zapier.com/apps/filter/integrations#help

 

 

 

TIP: Make sure to address the “Extra Fields” warnings in your Zap steps.

 


Thank you so much for this detailed response! Not having to use the Code is much simpler. I have set up the zap essentially identical to how you have outlined here but I’m running into an issue still.

 

When I run tests on each individual step, it runs no problem, and I am able to create the simulated ID no problem, but when I run a “Test Run” on all steps, it breaks. When we get to the step where it is getting the length of a string, it completely breaks, and has an odd input. When running the step in the “Edit Draft” mode, it’ll properly give the string length of “1” with an input of “1” but when doing the full test run, it has a string length of “22” with an input of “1753144564021_value}}”

 

I’ll post screenshots below with the individual step test and it’s return, then I will post the full test run and it’s return. 

 

 

 

Full Test Run:

To me it seems like it isn’t getting a proper value for it’s input, when it doesn’t seem to be an issue on the individual test runs. Any help would be appreciated. I really appreciate you taking the time to look at this!


@codemonkeylikesfritos 

Try turning the Zap ON and testing live.

Then check your Zap Runs history: https://zapier.com/app/history/

 

Somehow the mapped variable {{VAR}} is not getting treated properly and being stripped of the opening {{.

If the issue persists with live Zap Runs, then open a ticket with Zapier Support: https://zapier.com/app/get-help

 

 


Hi ​@codemonkeylikesfritos,
 
We just wanted to see how everything is going with your Zap. Did Troy's recommendation get the job done? Feel free to reach out if you need further assistance with your Zap. We're glad to address any concerns and assist you.
 
We're looking forward to your response.


Hello!

 

Thanks for your help. I tried setting it live, and it still persisted with that specific batch of emails that I was testing. I came back to it today, with a new batch and with a new email parser address and template, and it seems to be working. Hopefully that was it!

 

I appreciate all your help, thank you so much.


Hi ​@codemonkeylikesfritos,

 

Glad to hear that creating a new email parser address and template helped resolve the issue! Email parsing can be tricky if formats vary, so sticking to a consistent email structure is key. Keep testing with different batches, refine your template as needed, and monitor how it performs over time. If problems come up again, consider having a backup plan for exceptions or reach out to Zapier Support for further help. Great job troubleshooting!