0

I have made a Retrieve call using the below code, but am struggling to print the Email field values into a clean list.

I can get this output and can see the email addresses are pulling through:

{"Name":null,"Keys":null,"Type":"DataExtensionObject","Properties":[{"Name":"Email","Value":"[email protected]"}],"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: {"Name":null,"Keys":null,"Type":"DataExtensionObject","Properties":

The code I'm using is:

<script runat="server">
Platform.Load("Core","1.1.1");
<br><br>
var rr = Platform.Function.CreateObject("RetrieveRequest");<br><br>
Platform.Function.SetObjectProperty(rr, "ObjectType", "DataExtensionObject[1_Master_Data]");<br>
Platform.Function.AddObjectArrayItem(rr, "Properties", "Email");<br>
<br>
do {     var results = [0,0];
    var rows = Platform.Function.InvokeRetrieve(rr, results);  <br>  
    var runstatus = results[0];<br>
    var requestId = results[1];<br>
<br><br>
     if (rows != null) {<br>
        for (var i in rows) {<br>
          var output = rows[i];<br>
          Write(i + ": " + output + " <br/>");<br>
          Write(Stringify(rows[i]));<br>
        } <br>
    } <br>

    rr.ContinueRequest = requestId;<br>
} while (runstatus == "MoreDataAvailable")<br><br>
</script>

thank you

1 Answer 1

0

try this:

for (var i in rows) {

      var output = rows[i];<br>

      var properties = output["Properties"]

      var email = "";

      for (var j in properties) {
        var name = properties[j]["Name"];
        var value = properties[j]["Value"];

        if(name =="Email") //Find KeyValuePair for email
        {
           email = value;
           break;  // break the properties loop
        }

      }

      if(email!="")
      {
        Write("Email for row " + i + ": " + email + " <br/>");
      }else{
          Write("Can't find email for row " + i + "<br/>");
      }
}
0

You must log in to answer this question.

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