I am trying to use a script activity to update a data extension with the statuses of subscriber records. I have managed to get the code working but it will only add 2500 records. I have been reading about retrieving the OverallStatus to see if it produces the value "MoreDataAvailable". From the link below, I can see that you can use the retrieve method to do this. http://help.exacttarget.com/en-US/technical_library/web_service_guide/methods/retrieve/
There's also mention of a ContinueRequest method call. I can't find any documentation that mentions if this could be used with SSJS.
Is it possible to retrieve more than 2500 records with SSJS? Am I on the right track with the code below?
<script runat="server">
Platform.Load("core","1");
try {
var myList = List.Init('All Subscribers');
subs = myList.Subscribers.Retrieve({Property:"Status",SimpleOperator:"equals",Value:"Unsubscribed"});
var MasterPublicationList = DataExtension.Init("MasterPublicationList");
do {
var status = subs.Retrieve(rr);
//write to data extension
for (var i = 0; i < subs.length; i++) {
var subkeyUnsub = subs[i].SubscriberKey;
MasterPublicationList.Rows.Add({"Subscriber Key":subkeyUnsub,"Publication":"New Publication name","IsSubscribed":"False"});
}
var rr = Platform.Function.CreateObject("RetrieveRequest");
Platform.Function.SetObjectProperty(rr,"ContinueRequest",RequestID);
}while(status.OverallStatus == "MoreDataAvailable")
} catch (ex) {
Write("An error has occurred: " + Stringify(ex));
}
</script>
The error message I get is:
An error has occurred: {"message":"Object expected: Retrieve","jintException":"Jint.Native.JsException: Exception of type 'Jint.Native.JsException' was thrown.\r\n at Jint.ExecutionVisitor.Visit(MethodCall methodCall)\r\n at Jint.Expressions.MethodCall.Accept(IJintVisitor visitor)\r\n at Jint.ExecutionVisitor.Visit(MemberExpression expression)\r\n at Jint.Expressions.MemberExpression.Accept(IJintVisitor visitor)\r\n at Jint.ExecutionVisitor.Visit(VariableDeclarationStatement statement)\r\n at Jint.Expressions.VariableDeclarationStatement.Accept(IJintVisitor visitor)\r\n at Jint.ExecutionVisitor.Visit(BlockStatement statement)\r\n at Jint.Expressions.BlockStatement.Accept(IJintVisitor visitor)\r\n at Jint.ExecutionVisitor.Visit(TryStatement statement)","description":"Jint.Native.JsException: Object expected: Retrieve\r\nException of type 'Jint.Native.JsException' was thrown. - from Jint\r\n\r\n"}
Many thanks!