2

Is there an AMPScript's RaiseError function equivalent in SSJS in Marketing Cloud?

1 Answer 1

4

Yes - SSJS also has a 'RaiseError()' function:

Sample:

<script runat="server">     
     var StatusAndRequestID = [0,0];
     var newObject = Platform.Function.InvokeCreate(CreateRequest,StatusAndRequestID,Options);
     var status = StatusAndRequestID[0];
     var requestID = StatusAndRequestID[1];     if(Result != "OK") {
         Platform.Function.RaiseError("Create failed. Ensure your call successfully invoked the Create method.",false,"statusCode","3");
     }
</script>
2
  • 2
    You can also do a try/catch in SSJS. Dec 21, 2017 at 21:03
  • Hi Gortonington/Adam, when i use SSJS: do I have to do the Platform.Load("Core","1.1.5")command in order to use Write("<br>" + Stringify(e)) or RaiseError(..)? Or is it possible to just include a prefix like Platform.Function.Write(..)? I am uncertain how much of a performance aspect it is to load the Core 1.1.5 lib. Therefore i would like to get more insight in that. Jan 8, 2020 at 8:20

You must log in to answer this question.

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