Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save katydorjee/043455fc7316379140be17cbf98c3396 to your computer and use it in GitHub Desktop.
Save katydorjee/043455fc7316379140be17cbf98c3396 to your computer and use it in GitHub Desktop.
Use SSJS and WSProxy to add/update a subscriber status in Publication List within Salesforce Marketing Cloud
<script runat="server">
Platform.Load("core","1.1.1");
var subkey = "abc123";
var email = "foo@bar.com"
var prox = new Script.Util.WSProxy();
// Set specific BU context if required
// prox.setClientId({ "ID": 7279411 });
var sub = {
SubscriberKey: subkey,
EmailAddress: email,
Lists: [{
ID: '12345',
Status: 'Active'
}]
};
var options = {
SaveOptions: [{
PropertyName: "*",
SaveAction: "UpdateAdd"
}]
};
var resp = prox.createItem("Subscriber", sub, options);
Write("Response: " + Stringify(resp));
</script>
@Sohail-publicis
Copy link

How do I achieve same task using the DE. So I have DE where I have emailaddress and subscriberkey field. So I want the script read every record from DE and then certainly add to particular list? Is that possible?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment