UPDATE:
I tried UpdateDE with this code but it sent the same "unique code" when I did a test send to multiple emails"
%%[
var @customerCode, @codeDataExtension, @availableCodes, @randomIndex
set @codeDataExtension = "Codes_test" /* Replace with your data extension name */
/* Retrieve available codes from the data extension */ set @availableCodes = LookupRows(@codeDataExtension, "Status", "Available")
if RowCount(@availableCodes) > 0 then /* Randomly select a code from the available codes / set @randomIndex = Random(1, RowCount(@availableCodes)) set @customerCode = Field(Row(@availableCodes, @randomIndex), "Code") / Update the code's availability in the data extension to mark it as assigned */ UpdateDE(@codeDataExtension, 1, "Code", @customerCode, "Status", "Assigned")
else /* No available codes, handle the situation accordingly */ set @customerCode = "No available codes" endif ]%%
I have a DE that's contains a bunch of unique codes, is it possible to select codes in bunches (1 per email send) and then mark each code as 'used' once that particular code has been used in an email send (We cant send the same code twice). I thought using something like a AMPscript lookup function could work, and I tried the 'update data' function would but that doesn't work for emails..?
I've done something similar but that was in a bulk send where we had subscriber key and the codes in the same DE. This time we wont know which subscribers are to be sent a unique code until they complete an 'action'.
We'll have a file import that contains Subscriber keys and other info (not the codes) that will be delivered into SFMC via a file drop every 15 minutes (capturing people that completed 'said action'). We don't want to avoid manually assigning codes and manually sending out emails every 15 mins. So Im hoping that there was some AMPscript (Or anything other ideas reall) I could use...?
Thanks