0

I am trying to print the JSON values from the Rows.Retrieve function of SSJS but it always returns null

var stagingDE = DataExtension.Init("DE's External Key");
var data = stagingDE.Rows.Retrieve();
var newString = JSON.stringify(data, null, '\t');
Write("The Value " + newString );

Is there anything I am missing?

1 Answer 1

1

Try the following, I usually just call the Stringify() function from the Platform Functions of SSJS directly and check for a typeof 'Object' and length before I do anything with the response data.

I have not tested the below but it should work assuming the Data Extension External Key is correct and located within the same Business Unit you are executing the SSJS.

<script runat="server">
    Platform.Load('core', '1');

    var stagingDE = DataExtension.Init("DE's External Key");
    var data = stagingDE.Rows.Retrieve();

    if (typeof(data) == 'object' && data.length > 0) {
      Write("The Value " + Stringify(data));
    } else {
      Write("No Rows Found");
    }
</script>
2
  • This worked! Thanks a lot Commented Feb 20, 2020 at 7:57
  • Happy to help 🙂 Commented Feb 20, 2020 at 8:05

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.