How to use try-catch handling and submitNotification in Adobe Campaign?

adobe-campaign-try-catch-submitnotification

A good programmer is someone who always looks both ways before crossing a one-way street

Yesterday, I celebrated Christmas with my friends and family. The party did have a couple of kids. This is when we decided to have some fun. We gathered all the kids and tried to teach them some basics of programming. Everyone was assigned one kid and we had to teach one programming concept. I selected try-catch exception handling. It was amazing to see how quickly the kid grasped the concept.

Explaining try-catch to a 5-year-old

Try-catch is a weapon given to programmers in order to protect their source code from the dangers out there in the world. If the code that you write is an airplane then this makes sure that your code (airplane) does not experience turbulence and in case it does, this technique knows how to land the airplane safely. ( just like Tom Hanks in the movie Sully ) 🙂

Explaining try-catch to an adult

The try-catch statement allows you to test a block of code for errors. The try block contains the code to be run, and the catch block contains the code to be executed if an error occurs.

“submitNotification” allows you to create and submit a notification from a scenario.

In this example, we will use the try-catch statement and the submitNotification in Adobe Campaign Classic.

Example: with getUrl()

This code should get you started on using try-catch and submitNotification

/*
Author: Prajwal Shetty
Version: 1.0
Date:26/12/2018
Purpose: Using try-catch and submitNotification
*/

var lastRetrieval = getOption("INSMS_STOP_ID"); 

try
{
  logInfo("Value of the option : " + lastRetrieval)
  var url = "http://techonol.neolane.net//cus//soap.jsp?__sessiontoken=api/api&idOption=" + lastRetrieval + " "
  var xmlString = getUrl(url)
}
catch(e)
{
  logInfo("Can't get page content: " + url )
  logInfo("Error number: " + e )
  var xmlString = getUrl(url)

  // Send a message to someone
  logInfo("Error number: " + e )
  var iDeliveryId = nms.delivery.SubmitNotification
      ('notifError',
        <delivery>
          <targets _keepScenarioTarget='true'/>
        </delivery>
      );
}

Hope this helps.

As it is Christmas, let me spread some laughter.Enjoy!!!

Wishing you and your family a Merry Christmas and a Happy New Year!

[embedyt] https://www.youtube.com/watch?v=JeoCZScLEuo[/embedyt]

error: Content is protected !!