New answers tagged

2

I talked with one of the developers of SSJS and he told me: Redirect works by throwing an exception, so if it is inside a try it will indeed always end up in the catch statement. The one in the catch will overwrite the location set by the first one, and generate a new exception. It is similar to the ThreadAbort exceptions generated when calling the default ...


2

So, this is a known issue in .Net (which is what is used for rendering SFMC SSJS). Using Redirect will throw a Thread Abort Exception. Which I believe is what @SamWhitmore was stating in the official SFMC statement he provided. And as we do not have the control on catching exceptions that you do with .Net, we have to think outside the box. The best way to ...


0

The answer from Daniel Koch works pretty well and I can see no logical explanation why this is happen but the Redirect always throws an error. Instead of re-writing your code, I come up with this solution based of Daniel's answer: <script runat="server" language="javascript"> Platform.Load("core", "1.1.1"); try {...


1

I do not really know why - but I know how to restructure the code that it will work: <script runat="server"> var redirect = 'http://www.google.com' try{ //do your stuff here } catch(e) { redirect = 'http://www.yahoo.com' } Platform.Response.Redirect(redirect) </script>


0

Refer to the SSJS Redirect function syntax. Try the below code - <script runat="server" language="javascript"> Platform.Load("core", "1.1.1"); // Load core library try { Redirect("http://www.google.com",true); } catch(e) { Redirect("http://www.yahoo.com",true); } </script&...


0

In order to accomplish the desired functionality, you are going to want to use the PageReference class to do something like this: public PageReference save() { // Add the account to the database. insert account; // Send the user to the custom visualforce page for the new account. PageReference acctPage = new PageReference('/apex/...


0

You may try toasts. I used them to show messages on a redirect from visualforce page to the list view. sForce.one.showToast({“title”: “Error” , “message”: “Id not Found”, “type”: “error” }); Here is a simple article.


Top 50 recent answers are included