0

I'm new-ish to AMPScript. In our Marketing Cloud instance we have AMPScript used in various journeys, some of these are sourcing Data Extension content, others are trigger based and pulling directly from Salesforce CRM on send.

Some business critical emails, if the AMPScript data is blank on send (with order number etc), I'd like this send to be cancelled for this subscriber. Ideally an alert would be triggered, or this contact added to a Data Extension log for manual review so we can fix the issue prior to resending.

From what I've read online, I can't find anything to do this when using triggered send journeys pulling data directly from CRM. Can you please help provide the code example for this? Thanks!

1 Answer 1

1

Here’s what you need:

RaiseError

This function enables the suppression or cancellation of an email send. It is useful for exception handling in your code, if an unexpected result occurs.

Examplefrom the AMPscript.guide:

%%[

var @email, @couponRow, @couponCode

/* include the send context attributes or columns to record here */
set @email = AttributeValue("emailAddr")

set @couponRow = ClaimRow("CouponCodes", "IsClaimed", "EmailAddress", @email)

if not empty(@couponRow) then

  set @couponCode = Field(@couponRow, "CouponCode")

else

  RaiseError("No coupons available")

endif

]%%

Coupon code: %%=v(@couponCode)=%%

Source: https://ampscript.guide/raiseerror/

You must log in to answer this question.

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