0

I am working on a case where I am updating the DE When a error is occurring. There are total 100 records in DE where I am making the UpsertDE operation, I can see this code always update the top two records and skip rest of the records.

Here is the code.

%%[

set @lookupID = lookupID
set @rows = LookupRows("DDM_MD_Onboarding_Journey_EM_History","lookupID", @lookupID)
set @rowCount = rowcount(@rows)
if @rowCount > 0 then
  set @row = row(@rows, 1) 
  set @JourneyExitDate = field(@row,"JourneyExitDate")

IF @JourneyExitDate == '' THEN
  UpsertDE("DataExtension",1,"lookupID",@lookupID,"JourneyExitDate",Now())
  ENDIF
  ENDIF
]%%

%%[
set @sendEmail = 'False'
if @sendEmail == 'False' then
  RaiseError("Do not send", true, 1)  
endif
]%%

Is there anything I am missing in the code ?

3
  • Does it behave differently if you remove the RaiseError function?
    – zuzannamj
    Commented Nov 8, 2022 at 18:58
  • Thanks @zuzannamj Yes, then it is updating the records. Commented Nov 8, 2022 at 19:38
  • Can you try to test with test/sample Data... I did tried your code and seem to work for me... so I believe the issue might be related to Data! and not with AMPscript Commented Nov 9, 2022 at 7:23

1 Answer 1

2

I believe you need to specify the fifth Argument in your RaiseError() function. Without it, the data extension records are omitted when skipping.

This would be expected behavior: https://ampscript.guide/raiseerror/

5 Boolean False
Indicates whether the function preserves Data Extension rows inserted, updated, or deleted by AMPscript functions before error occurs, even if the process skips the Subscriber. A value of 1 will preserve data operations to Data Extensions before the error is raised, even if the Subscriber is skipped. A value of 0 does not preserve operations before the error.

not 100 % sure on arguments 3 and 4, but I think you can just leave them empty. While you're at it, I am a fan of giving the arguments variable names so someone who's not 100% documentation savvy can understand the raiseError configuration from the code:


SET @errorMsg = "Do not send"
SET @skipIndividualSubscriberOnly = true
SET @preserveRows = 1

if @sendEmail == 'False' then
  RaiseError(@errorMsg, @skipIndividualSubscriberOnly,,,@preserveRows)  
endif

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .