0

We're currently using Server Side JavaScript to access Data Extensions, but the performance here is abysmal (often over a second for a single row). So we tried accessing the Data Extensions via AMPscript and that seems to speed up the access by factor 100.

But we now have the problem that we need to get the data we retrieved in AMPscript over to JavaScript and so far we couldn't figure out an easy way to access the rowsets in JavaScript. Is this possible at all? I was hoping that it's just the same Object that we would get from DataExtension.Rows.Retrieve() in SSJS, but that's not the case. If we dump the result from DataExtension.Rows.Retrieve() it's a JSON array containing the keys and values per row. If we dump the object we retrieved in AMPscript we get System.Data.DataRow[] which seems to be a .NET class.

The only way we got it working so far was looping over the rowset in AMPscript and building a JSON string here that we then parse with eval() in SSJS. Is there a more convenient way?

So, basically what we're looking for is a way to have the same result as

var dataExtension = DataExtension.Init('DataExtensionName');
var result = dataExtension.Rows.Retrieve();

by using AMPscript to retrieve the data and handing it over to SSJS.

3
  • Why do you need to go back to SSJS? Seeing some of your code would be helpful. Commented Apr 18, 2017 at 11:00
  • Is this in an email or a landing/microsite/cloud page? Commented Apr 18, 2017 at 11:01
  • It's in a rather complex landing page with the application logic built completely in SSJS. So rebuilding it all with AMPscript is not really an option. Currently I wrote a little script that generates the part where we copy the AMPscript rowset to a SSJS struct that we then use instead of the Retrieve() calls. Works fine, but our code has now roughly doubled in size. If we could solve that with a one liner, that would be great.
    – korguell
    Commented Apr 19, 2017 at 12:49

0

You must log in to answer this question.