0

I use the RetrieveSalesforceObjects function within an Email that I send out in a Journey, recently some people have been failing in the email send.

Which I suspect is because of this line, I have tried doing an IF check to make sure the RowCount from RetrieveSalesforceObjects before I action anything but the emails are still failing, my suspicion is that the RetrieveSalesforceObjects is failing, maybe due to API issues and wondered how can I verify this?

Is there some sort of try catch I could do within email context? (I don't beleive SSJS try/catch will work in emails)

1 Answer 1

1

I don't think you can use SSJS try / catch in Emails, I would anyway leave SSJS out of emails in general.

There is RaiseError in AMPScript, but that doesn't really give you access to an error message from the Retrieve call.

The only workaround I know is to verify your code on a cloudpage and just wrap it in a try catch there. The errors you get from the SF API are actually quite good, so this approach is quite efficient.

Of course, you have to somehow get the subscriber context onto your cloudpage. For pure debugging you could really just hardcode an affected subscriber's Subscriberkey and work off that.

<script runat="server" type="text/javascript">
Platform.Load("core","1");
try {
</script>
<!--%%[
... AMPscript code ...
 
]%% -->
<script runat="server" type="text/javascript">
} catch (ex) {
    Variable.SetValue("@error", true)
    Variable.SetValue("@errorMsg", Stringify(ex))
}
</script>

Generally speaking I am not a fan of using RetrieveSalesforceObject in Emails as it isn't the fastest.

If you have no issue with the 15 minute delay, then what you could also try is to include the relevant object in the data stream and do a lookup on the Synchronized DE instead, which saves you the API call to SF and thus is both easier to debug and faster. Depends of course on your usecase.

Hope this helps!

You must log in to answer this question.

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