0

Basically I'm creating a script that retrieves all subscribers from a custom DE and unsubscribe them from the AllSubscribers. This code is going to be used inside a Script Activity which will execute daily.

The problem comes when I try to use the main function DataExtension.Init(). I've been using this method since the day I started to program in SSJS, but It doesn't work anymore.

My code:

<script runat="server">
    Platform.Load("Core","1.1.1");
    
    try{
    
      var myDE = DataExtension.Init("ExternalKey");
      var rows = myDE.Rows.Retrieve();

      Write("Rows: " + rows)
      
    }catch(error){
      Write("<br>error: " + Stringify(error));
    }
</script>

My DE has only 2 columns: ContactID and Email. It is non-sendable(I also tried to change it in sendable=true but nothing happend!). I also printed the object Retrieve and I noticed the method Rows.Retrieve doesn't exists anymore(the documentation do not mention this).

Are these methods still supported? Am I missing anything?

3
  • The code works fine for me. I just switched the core library to 1 instead of 1.1.1. Also retrieved the rows for a non sendable DE. Also, I have write as Write("Rows: " + Stringify(rows)). Ran the code on a cloud page Commented Feb 22, 2023 at 15:03
  • Looking at your another question, I suspect Init does not work, since you are trying to initiate your All Subscribers list as a Data Extension Commented Feb 24, 2023 at 14:32
  • How should I fix my code? I tried to do "List.Init" but it blocks me when I try to update records inside of it with this row: allSubs.Rows.Update({Status: "Unsubscribed"}, ["SubscriberKey"], subKey); Where "subKey" it's a variable that has all the subscriberKey I want to unsubscribe Commented Feb 27, 2023 at 9:02

1 Answer 1

0

The row set you was trying to retrieve in the DE is an array data, you cannot use Write function to "print" like that.

Try this:

<script runat="server">
    Platform.Load("Core","1.1.1");
    
    try{
    
      var myDE = DataExtension.Init("ExternalKey");
      var rows = myDE.Rows.Retrieve();
      Write(Stringify(rows));
      Write("<br>Rows: " + rows.length)
      
    }catch(error){
      Write("<br>error: " + Stringify(error));
    }
</script>

Here is the document for the method Rows.Retrieve

You must log in to answer this question.

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