Skip to content

Instantly share code, notes, and snippets.

@VijayaSankarN
Last active May 18, 2021 14:12
Show Gist options
  • Save VijayaSankarN/03e127edc67fa0042146328a9f1f36fe to your computer and use it in GitHub Desktop.
Save VijayaSankarN/03e127edc67fa0042146328a9f1f36fe to your computer and use it in GitHub Desktop.
<script runat="server">
Platform.Load("core", "1");
var prox = new Script.Util.WSProxy();
try {
var DE = "DataExtensionObject[MyDataExtension]", // Replace 'MyDataExtension' with your Data Extension Name
options = {SaveOptions: [{'PropertyName': '*', SaveAction: 'UpdateAdd'}]},
cols = ["EmailAddress", "SubscriberKey"], // Replace the field names matching your Data Extension
moreData = true,
reqID = null,
numItems = 0;
while(moreData) {
moreData = false;
var data = reqID == null ?
prox.retrieve(DE, cols) :
prox.getNextBatch(DE, reqID);
if(data != null) {
moreData = data.HasMoreRows;
reqID = data.RequestID;
for (var i = 0; i < data.Results.length; i++) {
var result_list = data.Results[i].Properties;
var obj = {};
for (k in result_list) {
var key = result_list[k].Name;
var val = result_list[k].Value
if (key.indexOf("_") != 0) obj[key] = val;
}
var publicationList = {
EmailAddress: obj[cols[0]],
SubscriberKey: obj[cols[1]],
Lists: [{
ID: 1234,
Status: 'Active'
}]
};
prox.updateItem('Subscriber', publicationList, options);
}
}
}
} catch(e) {
Write(Stringify(e));
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment