3

Disclaimer - Newbie to ExactTarget and AMPScript

Aside from Javascript and AMPScript, what languages (if any) are accepted as scripting languages in ExactTarget?

We have a Content Area full of a script that some consultants wrote and they left no comments or documentation on it. Now I have to edit the script and can't determine the language.

The full script is in a content area that is then called via a Script Interaction with this Javascript:

<script runat="server">
    Platform.Load("Core","1.1.1");
    try {
        var stream = ContentAreaByName("Content_Area_Name_Here");
        Write(TreatAsContent(stream));    
    } catch(e) {
        Write(Stringify(e));
    }
</script>

When I go into the content area to look at the code, it doesn't look like AMPScript to me, but if I try and debug it as JavaScript Visual Studio doesn't seem to accept it as valid Javascript.

Here's a sample of the script in the content area:

  var batch = lookupDE(page.settings.masterDE, 200, "MessageNumber",0);
  writeLn("Batch size: " + batch.length);

  for (i in batch) {
  var data = lookupDE(batch[i].MasterDE, 1, "ContactID", batch[i

].ContactID);

            // -- UPSERT EXTRACURRICULAR ACTIVITY
var extraCurricular = {"object":"TargetX_SRMb__Extra_Curricular_Activity__c","uniqueKey":[],"updateFields":[], "createFields" : []};
extraCurricular.uniqueKey.push({"field": "TargetX_SRMb__Contact__c", "value": row.ContactID });
extraCurricular.uniqueKey.push({"field": "Name", "value": "Sophomore Postcard" });
extraCurricular.updateFields.push({"field":"Fulfillment_Status__c", "value" : "Pending"});
extraCurricular.updateFields.push({"field":"Source__c", "value" : "Campaign"});
          SalesforceUpsert(extraCurricular);
         // -- EXTRA CURRICULAR ACTIVITY OBJECT

   } // for BATCH

  page.logArr.push({"end": Now()});
  writeLn( Stringify(page.logArr) );

  /* ====== FUNCTIONS ======= */
  function write(str){
    !str ? str = '' : str;
    if(debug){
      Write(str);
    }
  }
  function writeLn(str){
    !str ? str = '' : str;
    if(debug){
      write(str + '<br/>');
    }
  }

  function lookupDE(deName, max, keyName, keyValue) {
    var rtn = {};
    if (keyValue == "") {
      page.logArr.push({"errorLocation":"lookupDE","value":"keyValue blank"});
    } else {
      try {
        // attempt lookup row
        //***var DE1 = DataExtension.Init(deName);
        //***var data1 = DE1.Rows.Lookup(keyName, keyValue);
        var data1 = Platform.Function.LookupOrderedRows(deName, max,'InsertDate DESC',keyName,keyValue);
        page.results.lookupDESuccess = 1;
        return data1;
      } catch (e1) {
          page.logArr.push({"errorLocation":"lookupDE","value":e1});
      }
    }
  }

Any ideas how I can validate my edits to this script or at the very least determine exactly what it is so I can research the language before just editing it?

4

This is Marketing Cloud SSJS, so the functions used aren't available in native javascript. These modules/functions are loaded by marketing cloud and allow reading from dataextensions, etc. so the functions only work within marketing cloud.

Information on Server-Side JavaScript can be found here: Server-Side JavaScript Syntax Guide

| improve this answer | |
  • Thank you so much! That makes sense. I was wondering why it looked like Javascript but Visual Studio was rejecting it. I hasn't found that documentation previously. – R.Garton Mar 15 '17 at 20:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.