Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save katydorjee/49a49a0ea18e5a8d517cb10e36e7040a to your computer and use it in GitHub Desktop.
Save katydorjee/49a49a0ea18e5a8d517cb10e36e7040a to your computer and use it in GitHub Desktop.
Upsert (add or update) Publication list
updatePublicationList(12345, "003X123456789", "Unsubscribed")
function updatePublicationList(listId, subscriberKey, status) {
/*
status = Unsubscribed or status = Active
*/
var subArr = {
"SubscriberKey": subscriberKey,
"Lists": []
};
var listSub = {
"Status": status,
"ID": listId,
"Action": "Upsert"
};
subArr.Lists.push(listSub);
var subObj = Subscriber.Init(subscriberKey);
var status = subObj.Upsert(subArr);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment