0

According to the documentation, the SSJS function associated with the object list are : add, remove, retrieve and subscribers https://developer.salesforce.com/docs/atlas.en-us.mc-programmatic-content.meta/mc-programmatic-content/ssjs_listFunctions.htm

The remove function of a list removes this list.

How is it possible in SSJS to remove the subscribers of a list without actually removing this list ?

Thank you for your help

1 Answer 1

0

The SSJS below will remove any subscribers from the list that you initiate, using the external key of the list.

Since there is a limit of 2500 subscriber that can be retrieved, we're using a ternary to limit the amount of subscribers we're looping through to either 2500 or the total number of subscriber on the list if that number is less than 2500.

<script runat="server">
Platform.Load("Core","1");

var myList = List.Init("ExternalKeyofYourList");
var subs = myList.Subscribers.Retrieve();
var subsLength = subs.length >= 2500 ? 2500 : subs.length;

if (subsLength > 0) {
  for (var i = 0; i < subsLength; i++) {
    var subObj = Subscriber.Init(subs[i].SubscriberKey);
    var status = subObj.Remove();
  }
}
</script>
1
  • Thank you for your answer and for the explanation jake314159. It is working fine.
    – Teaiki
    Commented Feb 3, 2020 at 16:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .