0

In my data extension, I have two fields / columns:

  • JobID
  • DE_NAME

In this use case i want to receive the value for JobID and DE_NAME (1st row only)

var queryAllAccounts = true;    
    var cols = ["JobID","DE_Name"];
    

//define data extension from where record / value is needed
    var DE_ContentDetails_ExternalKey = "1111-1111-1111-1111";
    
var filter = {
    Property: "CustomerKey",
    SimpleOperator: "equals",
    Value: DE_ContentDetails_ExternalKey
};
    
    var tables = api.retrieve("DataExtensionObject[" + DE_ContentDetails_ExternalKey + "]", cols, filter, queryAllAccounts);
    

Write(tables.JobID);
Write("<br>");
Write(tables.DE_NAME);

Issue: I am getting blank output, why?

1

1 Answer 1

1

You need to use tables.Results as mentioned by @Jonas Lamberty. This is also mentioned in the doc: "The response is an object with four properties from the APiObjects SOAP items" https://developer.salesforce.com/docs/marketing/marketing-cloud/guide/ssjs_WSProxy_basic_retrieve.html

Other thing is related to filter. As you are using DataExtensionObject, this represents a row within a data extension so use a filter based on any column of your DE.

See below example for reference:

    var api = new Script.Util.WSProxy();
    var queryAllAccounts = true;
    var cols = ["SubscriberKey","EmailAddress"];

    var DE_ContentDetails_ExternalKey = "111-111-111-1111";

    var filter = {
        Property: "SubscriberKey",
        SimpleOperator: "isNotNull",
        Value: ""
};

    var tables = api.retrieve("DataExtensionObject[" + DE_ContentDetails_ExternalKey + "]", cols, filter, queryAllAccounts);

    //Write(Stringify(tables.Results));

    for (var i = 0; i < tables.Results.length; i++) {
 
        var result_list = tables.Results[i].Properties;
        var obj = { };
        for (k in result_list) {
            var key = result_list[k].Name;
            var val = result_list[k].Value
            Write(key + "<BR>");
            Write(val + "<BR>");
            }
}

or if you want to keep it simple, you can use SSJS DataExtension.Init and Rows.Retrieve(); Retrieving and Displaying the records from a data Extension using SSJS or WSProxy

You must log in to answer this question.

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