我有一个共享的DE(CampaignRegisteration)。
此DE有一个Campasigns列表。当我执行以下代码发送优惠券时,我需要使用此信息更新此DE。
%%[
var @em, @couponRow, @couponCode , @DEName,@LocalBG ,@ClaimDate,@SubId,@CampName,@VoucherSent
var @UnusedCount,@UsedCount,@Threshold,@Threshold_flg,@Empty_Flg,@rowsUpdated
if _messagecontext == "PREVIEW" then
set @couponCode = "XX TEST XX"
else
set @em = AttributeValue("emailAddr")
set @Threshold_flg = false
set @Empty_Flg = false
set @DEName = "CAM-2v9g2q2" /* Replace CAM-2v9g2q2 with actual camp code everywhere */
set @LocalBG = "NLD" /* Insert the local BG 3 digit country code */
set @couponRow = ClaimRow("CAM-2v9g2q2","IsClaimed", "EmailAddress", @em, "JobID", JobID, "ListID", ListID, "BatchID", _JobSubscriberBatchID, "SubscriberID", SubscriberID)
if not empty(@couponRow) then
set @couponCode = Field(@couponRow, "CouponCode")
set @ClaimDate = Field(@couponRow, "ClaimedDate")
set @SubId = Field(@couponRow, "SubscriberID")
set @UnusedCount = Subtract(Lookup("ENT.CampaignRegisteration","VoucherUnused","Market", @LocalBG, "CampaignNo", @DEName) ,1)
set @UsedCount = Add(Lookup("ENT.CampaignRegisteration","VoucherUsed","Market", @LocalBG, "CampaignNo", @DEName) ,1)
set @Threshold = Lookup("ENT.CampaignRegisteration","Threshold","Market", @LocalBG, "CampaignNo", @DEName)
set @CampName = Lookup("ENT.CampaignRegisteration","CampaignName","Market", @LocalBG, "CampaignNo", @DEName)
set @Threshold_flg = iif(@UnusedCount <= @Threshold,'true','false')
set @Empty_Flg = iif(@UnusedCount <= 0,'true','false')
set @rowsUpdated = UpdateDE('ENT.CampaignRegisteration',2,'Market', @LocalBG, 'CampaignNo', @DEName,'VoucherUnused',@UnusedCount,'VoucherUsed',@UsedCount,'LatestSentDate',SystemDateToLocalDate(Now(1)),'Notification_Threshold',@Threshold_flg,'Notification_Empty',@Empty_Flg)
InsertDE("ENT.SentVouchers","CouponCode",@couponCode,"EmailAddress",@em,"Market",@LocalBG,"CampName",@CampName,"CampId",@DEName,"SubscriberID",@SubId,"ClaimedDate",@ClaimDate)
else
RaiseError("No coupons available", false)
endif
endif
]%%
<p>
Voucher Unsed = %%=v(@UnusedCount)=%%
<br/>
Voucher Used = %%=v(@UsedCount)=%%
<br/>
</p>
<p> Please use discount code %%=v(@couponCode)=%% or scan it <img alt="barcode" border="0" height="100" hspace="0" src="%%=BarCodeURL(@couponCode,'DataMatrix', 100, 100, 0)=%%" style="width: 100px; height: 100px" title="barcode" width="100"></p>
行
set @rowsUpdated = UpdateDE('ENT.CampaignRegisteration',2,'Market', @LocalBG, 'CampaignNo', @DEName,'VoucherUnused',@UnusedCount,'VoucherUsed',@UsedCount,'LatestSentDate',SystemDateToLocalDate(Now(1)),'Notification_Threshold',@Threshold_flg,'Notification_Empty',@Empty_Flg)
负责更新DE。
当我进行4个子发送时,上面的行仅运行1次。
在运行之前,广告系列注册具有:
未使用的代金券= 344 已使用优惠券= 0
运行后, 未使用的代金券= 343 已使用优惠券= 1
我的期望是: 未使用的代金券= 340 已使用优惠券= 4
您能否让我知道我的期望是对还是错,以及为什么代码以这种方式行事