I need to skip sending an email based on the evaluation of a condition that I'm defining in an AMPscript block in my email, and also make a POST request to a an HTTP endpoint.
Here's what I have:
<script runat=server language=ampscript> var @response, @result set @result='fail' /* hardcoded for example purpose */ if @result=='fail' then HTTPPost('http://requestb.in/1km46cl1', 'text/xml', Concat('result failed for subscriber ',_subscriberkey), @response ) RaiseError("Email skipped", true) endif </script>
This works fine; if I generate a Preview for a Subscriber, then if
@result=='fail' evaluates to true, the POST request is made and I see the
However, when I use this email in a Triggered Send, the email is moved to the Error queue (which I would expect), but the POST request is not made. It's almost as if OMM evaluates the AMPscript for any
RaiseError() function and aborts sending the email (instead of parsing it from top to bottom). Does anyone know of a solution?