1

So I am attempting to write code that returns more than 2500 records so that I can use the data for display on the page (I know this will be slow but it is business' requirement). There are currently only 7 records in my table so it is returning the correct amount of records. What I don't understand is why it is returning null for everything.

Page Code:

<!doctype html>
<html>
  <head>
    <meta charset="utf-8">
    <title></title>
    <meta name="description" content="">
    <meta name="viewport" content="width=device-width, initial-scale=1">
  </head>
  <body>
    <h2>
      hello
    </h2>
    <script runat="server">

      Platform.Load("Core","1.1.1");


      var rr = Platform.Function.CreateObject("RetrieveRequest");
      Platform.Function.SetObjectProperty(rr, "ObjectType", "DataExtensionObject[mydataextensionid]"); //i removed my id from here for posting

      Platform.Function.AddObjectArrayItem(rr, "Properties", "email1_TXT");
      Platform.Function.AddObjectArrayItem(rr, "Properties", "email2_TXT");
      Platform.Function.AddObjectArrayItem(rr, "Properties", "email3_TXT");
      Platform.Function.AddObjectArrayItem(rr, "Properties", "email4_TXT");
      Platform.Function.AddObjectArrayItem(rr, "Properties", "email5_TXT");
      Platform.Function.AddObjectArrayItem(rr, "Properties", "email6_TXT");
      Platform.Function.AddObjectArrayItem(rr, "Properties", "email7_TXT");
      Platform.Function.AddObjectArrayItem(rr, "Properties", "email8_TXT");
      Platform.Function.AddObjectArrayItem(rr, "Properties", "email9_TXT");
      Platform.Function.AddObjectArrayItem(rr, "Properties", "email10_TXT");
      Platform.Function.AddObjectArrayItem(rr, "Properties", "Phone1_TXT");
      Platform.Function.AddObjectArrayItem(rr, "Properties", "Phone2_TXT");
      Platform.Function.AddObjectArrayItem(rr, "Properties", "Phone3_TXT");
      Platform.Function.AddObjectArrayItem(rr, "Properties", "Phone4_TXT");
      Platform.Function.AddObjectArrayItem(rr, "Properties", "Phone5_TXT");
      Platform.Function.AddObjectArrayItem(rr, "Properties", "Phone6_TXT");
      Platform.Function.AddObjectArrayItem(rr, "Properties", "Phone7_TXT");
      Platform.Function.AddObjectArrayItem(rr, "Properties", "Phone8_TXT");
      Platform.Function.AddObjectArrayItem(rr, "Properties", "Phone9_TXT");
      Platform.Function.AddObjectArrayItem(rr, "Properties", "Phone10_TXT");
      Platform.Function.AddObjectArrayItem(rr, "Properties", "AlphaVIN_FLG");
      Platform.Function.AddObjectArrayItem(rr, "Properties", "VIN_No");
      Platform.Function.AddObjectArrayItem(rr, "Properties", "FirstName");
      Platform.Function.AddObjectArrayItem(rr, "Properties", "LastName");
      Platform.Function.AddObjectArrayItem(rr, "Properties", "AddressLine1_TXT");
      Platform.Function.AddObjectArrayItem(rr, "Properties", "AddressLine2_TXT");
      Platform.Function.AddObjectArrayItem(rr, "Properties", "Make_TXT");
      Platform.Function.AddObjectArrayItem(rr, "Properties", "ModelYear_TXT");
      Platform.Function.AddObjectArrayItem(rr, "Properties", "Salutation_TXT");
      Platform.Function.AddObjectArrayItem(rr, "Properties", "MiddleInitial");
      Platform.Function.AddObjectArrayItem(rr, "Properties", "State_CD");
      Platform.Function.AddObjectArrayItem(rr, "Properties", "Model_TXT");
      Platform.Function.AddObjectArrayItem(rr, "Properties", "Phone1Type_TXT");
      Platform.Function.AddObjectArrayItem(rr, "Properties", "Phone2Type_TXT");
      Platform.Function.AddObjectArrayItem(rr, "Properties", "Phone3Type_TXT");
      Platform.Function.AddObjectArrayItem(rr, "Properties", "Phone4Type_TXT");
      Platform.Function.AddObjectArrayItem(rr, "Properties", "Phone5Type_TXT");
      Platform.Function.AddObjectArrayItem(rr, "Properties", "Phone6Type_TXT");
      Platform.Function.AddObjectArrayItem(rr, "Properties", "Phone7Type_TXT");
      Platform.Function.AddObjectArrayItem(rr, "Properties", "Phone8Type_TXT");
      Platform.Function.AddObjectArrayItem(rr, "Properties", "Phone9Type_TXT");
      Platform.Function.AddObjectArrayItem(rr, "Properties", "Phone10Type_TXT");
      Platform.Function.AddObjectArrayItem(rr, "Properties", "Zip4_TXT");
      Platform.Function.AddObjectArrayItem(rr, "Properties", "Zip3_TXT");
      Platform.Function.AddObjectArrayItem(rr, "Properties", "City_Name");
      Platform.Function.AddObjectArrayItem(rr, "Properties", "Country");
      Platform.Function.AddObjectArrayItem(rr, "Properties", "email1Type_TXT");
      Platform.Function.AddObjectArrayItem(rr, "Properties", "email2Type_TXT");
      Platform.Function.AddObjectArrayItem(rr, "Properties", "email3Type_TXT");
      Platform.Function.AddObjectArrayItem(rr, "Properties", "email4Type_TXT");
      Platform.Function.AddObjectArrayItem(rr, "Properties", "email5Type_TXT");
      Platform.Function.AddObjectArrayItem(rr, "Properties", "email6Type_TXT");
      Platform.Function.AddObjectArrayItem(rr, "Properties", "email7Type_TXT");
      Platform.Function.AddObjectArrayItem(rr, "Properties", "email8Type_TXT");
      Platform.Function.AddObjectArrayItem(rr, "Properties", "email9Type_TXT");
      Platform.Function.AddObjectArrayItem(rr, "Properties", "email10Type_TXT");
      Platform.Function.AddObjectArrayItem(rr, "Properties", "Outreach_VIN_No");
      Platform.Function.AddObjectArrayItem(rr, "Properties", "PCRM_Outreach_Flag");
      Platform.Function.AddObjectArrayItem(rr, "Properties", "PG_Type_CD");
      Platform.Function.AddObjectArrayItem(rr, "Properties", "TakataRecallIndicator");
      Platform.Function.AddObjectArrayItem(rr, "Properties", "VIN_Id");
      Platform.Function.AddObjectArrayItem(rr, "Properties", "Zip55");
      Platform.Function.AddObjectArrayItem(rr, "Properties", "NoOfEmail");
      Platform.Function.AddObjectArrayItem(rr, "Properties", "NoOfMobile");
      Platform.Function.AddObjectArrayItem(rr, "Properties", "NoOfPhone");
      Platform.Function.AddObjectArrayItem(rr, "Properties", "Zip5");
      Platform.Function.AddObjectArrayItem(rr, "Properties", "Urbanization");


      try{
        do { 
          var results = [0,0];

          var rows = Platform.Function.InvokeRetrieve(rr, results);

          var runstatus = results[0];
          var requestId = results[1];

          for (var i in rows) {
            var rNOMBRE = rows[i].toString();


            Write(i + ": " + rNOMBRE + " <br/>");

            var str = objToString(rows[i]);
            Write(str);

          } 

          rr.ContinueRequest = requestId;
        } while (runstatus == "MoreDataAvailable")
      }catch(err){
        Write("err found : " + err.message);
      }


        function objToString (obj) {
          var str = '';
          for (var p in obj) {
            if (obj.hasOwnProperty(p)) {
              str += p + '::' + obj[p] + '\n';
            }
          }
          return str;
        }
    </script>

  </body>
</html>

outputs like:

0: [object Object] 
Name::null Keys::null Type::DataExtensionObject Properties::,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, Client::null PartnerKey::null PartnerProperties::null CreatedDate::0001-01-01T00:00:00.000 CreatedDateSpecified::false ModifiedDate::null ModifiedDateSpecified::false ID::0 IDSpecified::false ObjectID::null CustomerKey::null Owner::null CorrelationID::null ObjectState::null IsPlatformObject::false IsPlatformObjectSpecified::false 1: [object Object] 
Name::null Keys::null Type::DataExtensionObject Properties::,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, Client::null PartnerKey::null PartnerProperties::null CreatedDate::0001-01-01T00:00:00.000 CreatedDateSpecified::false ModifiedDate::null ModifiedDateSpecified::false ID::0 IDSpecified::false ObjectID::null CustomerKey::null Owner::null CorrelationID::null ObjectState::null IsPlatformObject::false IsPlatformObjectSpecified::false 2: [object Object] 
Name::null Keys::null Type::DataExtensionObject Properties::,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, Client::null PartnerKey::null PartnerProperties::null CreatedDate::0001-01-01T00:00:00.000 CreatedDateSpecified::false ModifiedDate::null ModifiedDateSpecified::false ID::0 IDSpecified::false ObjectID::null CustomerKey::null Owner::null CorrelationID::null ObjectState::null IsPlatformObject::false IsPlatformObjectSpecified::false 3: [object Object] 
Name::null Keys::null Type::DataExtensionObject Properties::,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, Client::null PartnerKey::null PartnerProperties::null CreatedDate::0001-01-01T00:00:00.000 CreatedDateSpecified::false ModifiedDate::null ModifiedDateSpecified::false ID::0 IDSpecified::false ObjectID::null CustomerKey::null Owner::null CorrelationID::null ObjectState::null IsPlatformObject::false IsPlatformObjectSpecified::false 4: [object Object] 
Name::null Keys::null Type::DataExtensionObject Properties::,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, Client::null PartnerKey::null PartnerProperties::null CreatedDate::0001-01-01T00:00:00.000 CreatedDateSpecified::false ModifiedDate::null ModifiedDateSpecified::false ID::0 IDSpecified::false ObjectID::null CustomerKey::null Owner::null CorrelationID::null ObjectState::null IsPlatformObject::false IsPlatformObjectSpecified::false 5: [object Object] 
Name::null Keys::null Type::DataExtensionObject Properties::,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, Client::null PartnerKey::null PartnerProperties::null CreatedDate::0001-01-01T00:00:00.000 CreatedDateSpecified::false ModifiedDate::null ModifiedDateSpecified::false ID::0 IDSpecified::false ObjectID::null CustomerKey::null Owner::null CorrelationID::null ObjectState::null IsPlatformObject::false IsPlatformObjectSpecified::false 6: [object Object] 
Name::null Keys::null Type::DataExtensionObject Properties::,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, Client::null PartnerKey::null PartnerProperties::null CreatedDate::0001-01-01T00:00:00.000 CreatedDateSpecified::false ModifiedDate::null ModifiedDateSpecified::false ID::0 IDSpecified::false ObjectID::null CustomerKey::null Owner::null CorrelationID::null ObjectState::null IsPlatformObject::false IsPlatformObjectSpecified::false

1 Answer 1

1

I'd suggest using the new WSProxy library. This retrieving Email objects, but it can be easily adapted to retrieve DataExtensionObject/Rows.

This example shows how the HasMoreRows part works:

<script type="text/javascript" runat="server">

Platform.Load("core", "1.1.5");

var prox = new Script.Util.WSProxy(),
    objectType = "Email",
    cols = ["Name"],
    moreData = true,
    reqID = null,
    numItems = 0;

while(moreData) {
    moreData = false;
    var data = reqID == null ?
           prox.retrieve(objectType, cols) :
           prox.getNextBatch(objectType, reqID);

    if(data != null) {
        moreData = data.HasMoreRows;
        reqID = data.RequestID;
        if(data && data.Results) {
            for(var i=0; i< data.Results.length; i++) {
                Platform.Response.Write(data.Results[i].Name);
                numItems++;
            }
        }
    }
}
Platform.Response.Write("<br />" + numItems + " total " + objectType);

</script>

You must log in to answer this question.

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