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!