0

I'm trying to create an exclusion script based on the output of a Code snippet which looks like:

<script language="javascript" runat="server"> 
Platform.Load("core", "1");

var AttributesJsonJs = Platform.Function.ParseJSON(Variable.GetValue("@AttributesJsonDE"));

if(AttributesJsonJs){
 Variable.SetValue("@sendEmail",AttributesJsonDE.sendEmail);
 
} else {
 Variable.SetValue("@sendEmail","");

}
</script>

%%[ VAR @canSendEmail IF @sendEmail == "true" THEN SET @canSendEmail = "canSendEmail" ELSE SET @canSendEmail = "dontSendEmail" ENDIF ]%%

%%=v(@canSendEmail)=%%

My exclusion script looks like:

TreatAsContent(ContentArea(127290))=="dontSendEmail"

When I make a call to send the triggered send I can see the queue being filled, however nothing is being send, even if the output doesn't match the exclusion script. Any ideas on what I'm doing wrong?

Thanks a lot!


Update DE Record This is the record information for the column Attributes

{"sendEmail":"true","orderHasBeenFulfilled":"true","POS_StoreCashier":"Testverkoper"}


I've also tried the following:

%%[
var @str, @var, @sendEmail

/* Set the value to check */ 
SET @var = false

/* Set the string to check */ 
Set @str = AttributeValue(sendEmail)

/* Does it match */ 
if IndexOf(@str,@var) > 0 then 
    Set @sendEmail = "dontSendReceipt" 
else 
    Set @sendEmail = "sendReceipt" 
endif 
]%%

%%=v(@sendEmail)=%%

When testing the email in preview and test the correct value is being populated. My exclusion script looks now like this:

TreatAsContent(ContentBlockbyID('127567')) == dontSendReceipt

But still no luck..

10
  • If you remove the script from your send definition and add it to your email body, what does it show? Mar 16 at 18:59
  • Hi @AdamSpriggs, it shows canSendEmail, which is correct Mar 16 at 19:19
  • And if you capture the RequestID from your Triggered Send API call and retrieve the delivery details using the /messaging/v1/messageDefinitionSends/key:{{TSDKey}}/deliveryRecords/{{RequestID}} REST route what do you get? Mar 16 at 23:31
  • @AdamSpriggs, It says it's being queued. When I check the email that is being generated the code gives me the output that I need to be able to send the email, however nothing is happening Mar 17 at 7:04
  • If it doesn't get sent -- the deliveryRecord result should show something once it gets past "queued". Mar 17 at 11:59
0

After multiple different solutions, I've decided to go for the RaiseError function. The exclusion will not happen too many times, so this should be sufficient enough.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.