AMPSCRIPT PLAYGROUND

 LEARN AMPSCRIPT LIKE A PRO

The following sections include a list of possible  error and relevant information to review AMPSCRIPT code,  an Alert notification will be displayed relating to any of these errors that might occur in you code block.
I created a cloud page that will help developers debug their AMPSCRIPT 
code block and fix the issue quickly locating the line where the error occurred. 


1. TRYING TO INSERT DATA INTO A DATA EXTENSION THAT DONT EXIST

%%[
    InsertDE('SomeDE','FirstName',FirstName, 'LastName',LastName)
]%%

  AFTER UPDATING THE CODE



2. TRYING TO INSERT DUPLICATE  INTO A DATA EXTENSION 





INSERTDE FUNCTION USES MSSQL SERVER TO PERFORM INSERT QUERY AND THROWS SQLEXCEPTION DUE TO PRIMARY KEY VIOLATIONS.
ISN'T IT INTERESTING ? AMPSCRIPT IS A WRAPPER FOR .NET MSSQL SERVER NATIVE.

3. TRYING TO INSERT DATA INTO A DATA EXTENSION WITH INVALID ATTRIBUTE



4. TRYING TO INSERT NULL VALUES



5. TRYING TO CALL CONTENT BLOCK THAT CONTAINS SYNTAX ERROR



LIST OF ERROS THAT OCCURS USING AMPSCRIPT BLOCK

1. OMM_GETSUBLSTERR
The OMM_GETSUBLSTERR indicates there was an issue finding or building the send list.

2. OMM_INVALIDSTATE
The OMM_INVALIDSTATE error can occur when a Data Extension used as part of the send is deleted. This error can also occur when sending from an unverified From Address. Ensure the From Address is registered for your account.

3. OMM_INVALID_FUNCT_PARAM
The error code OMM_INVALID_FUNCT_PARAM is observed when an AMPscript function in your email code is unable to execute due to invalid function parameters. Review the error message in the alert notification for the name of the AMPscript function in your email that is causing this issue. 

4. OMM_JOB_STATUS_INTERRUPT
The OMM_JOB_STATUS_INTERRUPT indicates there was an issue processing the send. This error may result in a partial send where some of your audience received the email but others did not. If you plan on sending to the remaining audience, cancel the job from the Tracking screen in Email Studio.

5. OMM_JOBDETAIL_ERR
The OMM_JOBDETAIL_ERR typically indicates there is a system issue with the send. This is not expected behavior and is addressed under this Known Issue. Follow the workaround in the Known Issue to resume the sends. 

6. OMM_SCRIPT_SYNTAX_ERR
An OMM_SCRIPT_SYNTAX_ERR error occurs when a syntax issue in your AMPscript code is encountered that prevents the code from compiling. For example an unexpected character or an invalid property or expression can cause the AMPscript to fail with this error. Please review your AMPscript code for the syntax error highlighted in the alert notification.

7.OMM_SUBBATCHERR
The OMM_SUBBATCHERR can happen when the Data Extension being used as part of a send is cleared/overwritten while the send is in progress. Ensure any Imports, Filters, or Query activities do not overwrite the Data Extension until the send is complete. This error can also occur if the Data Extension used in a send is renamed while the send is in progress.

 

8.  OMM_VAR_SET_EXPR_INVALID
An OMM_VAR_SET_EXPR_INVALID is encountered when a SET statement in the AMPscript of your email cannot be compiled. As seen in the example provided below, this error can occur when you set a variable to an attribute that does not exist or the returned value of an AMPscript function call that fails during execution. As a result, you will often see OMM_SCRIPT_SYNTAX_ERR errors nested inside a OMM_VAR_SET_EXPR_INVALID error. Please review and test your email code to correct this error.


SOURCE CODE :
<!DOCTYPE html>
<html>
  <head>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0" />
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
    <style class="main_style">
      .layout-canvas-g {
        background-color: #fff;
        border: none;
        -webkit-box-sizing: border-box;
        -moz-box-sizing: border-box;
        box-sizing: border-box;
        padding: 0;
        width: 100%;
      }
      .layout-canvas-g > .header,
      .layout-canvas-g > .section,
      .layout-canvas-g > .footer {
        position: relative;
        overflow: hidden;
        width: 100%;
        word-wrap: break-word;
      }
      .layout-canvas-g > .section {
        margin: 10px 0;
      }
      .layout-canvas-g > .section > .columns {
        -webkit-box-sizing: border-box;
        -moz-box-sizing: border-box;
        box-sizing: border-box;
        word-wrap: break-word;
      }
      body {
        color: #000;
        font-family: Arial;
        font-size: 12px;
        margin: 0 auto;
        max-width: 1280px;
      }
      @media only screen and (max-width: 480px) {
        .mobile-hidden {
          display: none !important;
        }
        .responsive-td {
          width: 100% !important;
          display: block !important;
          padding: 0 !important;
        }
      }
      .layout-canvas-g > .section > .columns {
        width: 100%;
      }
    </style>
  </head>
  <body class="mx-auto" style="width: 600px;">
    <div  style="text-align: center;padding: 10px;">
      <!---------------------------------------  AMPSCRIPT BLOCK STARTS HERE --------------------------------------->
      <script runat="server" defer>
        Platform.Load("Core","1.1.1");
        try{
      </script>
      %%[
       /* InsertDE('SomeDE','FirstName',FirstName, 'LastName',LastName, 'CreatedDate',NOW()) */
        %%=ContentBlockbyKEY("LOOKUPAMPSCRIPT")=%%
     ]%%
      %%[
          SET @successMessage='All Good'
      ]%%
      <script runat="server">
        }
        catch(e){
          var length=e.description.length;
          var indexof=e.description.indexOf("ExactTarget.OMM.InvalidFunctionException");
          Variable.SetValue("@errordescription",(e.description.substring(indexof,length)));
          Variable.SetValue("@errorMessage",(e.message));
        }
      </script>
      <!---------------------------------------  AMPSCRIPT BLOCK ENDS   HERE --------------------------------------->
    </div>
    %%[ IF NOT EMPTY(@successMessage) THEN]%%
    <div class="alert alert-success !important" role="alert" >
      <button type="button" class="close" data-dismiss="alert" aria-label="Close">
        <span aria-hidden="true">&times;</span>
      </button>
      <h4 class="alert-heading">Well done!
      </h4>
      <p>Aww yeah, There is no error in the code.
      </p>
      <hr>
    </div>
    %%[ENDIF  IF NOT EMPTY(@errorMessage) THEN]%%
    <div class="alert alert-warning  !important" role="alert">
      <button type="button" class="close" data-dismiss="alert" aria-label="Close">
        <span aria-hidden="true">&times;</span>
      </button>
      <strong>Error Occurred!</strong>
      <hr>   %%=v(@errorMessage)=%%
      <hr> %%=v(@errordescription)=%%
    </div>
    %%[ENDIF]%%
    <br/>
    <br/>
  </body>
</html>

Comments

Most Viewed

CLOUD PAGE ENABLEMENT - PART 1

EMAIL NOT SENT IN JOURNEY BUILDER

CONSIDERATIONS FOR JOURNEY BUILDER

Understanding Transactional Messaging

Preference Center Demystified


Knowledge Article

Popular Posts

CLOUD PAGE ENABLEMENT - PART 1

EMAIL NOT SENT IN JOURNEY BUILDER

CONSIDERATIONS FOR JOURNEY BUILDER

Understanding Transactional Messaging

Preference Center Demystified

Journey Builder REST API Documentation

Share with Friends

Disclaimer:

The information provided on this technical blog is for general informational purposes only. As a SFMC (Salesforce Marketing Cloud) Technical Architect, I strive to offer accurate and up-to-date content related to SFMC and its associated technologies. However, please note that technology is constantly evolving, and the information provided may become outdated or inaccurate over time.

The content published on this blog represents my personal views and experiences as a SFMC Technical Architect and does not necessarily reflect the official views or opinions of any organization or employer I may be affiliated with.

While I make every effort to ensure the accuracy and reliability of the information presented, I cannot guarantee its completeness, suitability, or applicability to your specific circumstances. Therefore, it is essential to verify any information provided and make your own independent assessments or seek professional advice if needed.

Furthermore, any actions taken based on the information provided on this blog are at your own risk. I shall not be held liable for any damages, losses, or inconveniences arising from the use of the information presented here.

Please keep in mind that SFMC and its associated technologies are complex and require technical expertise for proper implementation and management. It is recommended to consult with qualified professionals or official SFMC documentation for comprehensive guidance.

Finally, please note that any product or company names mentioned on this blog are trademarks or registered trademarks of their respective owners. The mention of these trademarks or registered trademarks does not imply any endorsement or affiliation with the blog.

By accessing and using this blog, you agree to the terms of this disclaimer. If you do not agree with any part of this disclaimer, please refrain from using this blog.