I have a large number of subscribers I need need to move from an ExactTarget data extension into different lists using ssjs. This is the basic script I am using
<pre>
<script runat="server">
Platform.Load("core","1");
var tempDE = DataExtension.Init("Temp");
var oldList = List.Init(2830)
var newList = List.Init(2833)
var arrayLength = 1;
while (arrayLength > 0) {
var tempDeResults = tempDE.Rows.Retrieve();
var arrayLength = tempDeResults.length;
if (arrayLength > 50) { arrayLenght = 50; }
for (var i = 0; i < arrayLength; i++) {
var sub = tempDeResults[i]['Email Address'];
var moveto = newList.Subscribers.Upsert(sub);
var delfrom = oldList.Subscribers.Unsubscribe(sub);
tempDE.Rows.Remove(['Email Address'],[sub]);
}
location.reload(true);
}
</script></pre>
What I am trying to do is have the script run for 50 subscribers, and then reload for the next 50, as if I have clicked the reload button, but that is not working great, and it get's aborted.
My question what is the best way of say adding 2500 contacts to a list by running s script once? How do I get it to break and restart those requests after 50 subscribers so those calls don't hang? How do I add subscribers asynchronously using ssjs?
Any help here would be great. The more detail the better.
Thanks