How do we delete subscribers (emails) from Auto suppression list using SSJS. Also, Auto suppression list maintain at SF end or application level.

up vote 2 down vote accepted

Delete All Records

The following script uses WSProxy to delete all records from an auto-suppression list.

Replace AutoSuppressionExternalKey with the external key of your Auto Suppression List.

<script type="javascript" runat="server">
Platform.Load("core", "1");

var prox = new Script.Util.WSProxy();
var res;
var autoSupListDE = 'AutoSuppressionExternalKey'

function clearAutoSuppressionList(){
    var action = 'ClearData';
    var options = {};
    var props = {
        CustomerKey:autoSupListDE
    };
    var res = prox.performItem("DataExtension",props,action,options);
}

function main(){
  clearAutoSuppressionList();
}

main();
</script>

Delete Single Record

Piyush asked how to delete a specific record from an auto suppression list. As auto-suppression lists are effectively Data Extensions, the following SSJS platform function will remove an individual record (based on their email address) from an auto-suppression list:

<script runat="server">
   var deleteRow = Platform.Function.DeleteData('AutoSuppressionExternalKey',['Email Address'],['sam@sample.com']);
</script>

Delete Multiple Records

Piyush also ask how to iterate through a Data Extension containing email addresses for deletion, then remove them from the auto suppression list.

The following script will achieve this, where toDelete is the External Key of the DE containing Email Addresses to delete (which includes a field named 'Email' with the email addresses for deletion), and AutoSuppressionExternalKey is the external key of the auto suppression list.

<script runat="server">

Platform.Load("Core","1.1.1");

     var deleteEmails = DataExtension.Init("toDelete");
     var data = deleteEmails.Rows.Retrieve();

     for (var i=0; i < data.length; i++) {

       var email = data[i].Email;

       var deleteRow = Platform.Function.DeleteData('AutoSuppressionExternalKey',['Email Address'],[email]);

    };

</script>
  • Thank you very much Eliot. Also, what if I want to delete specific one from list ? – Piyush Rastogi Oct 19 at 6:26
  • I have updated my answer to provide this option too. – Eliot Harper Oct 21 at 20:31
  • Thanks Eliot for your kind response. One last ask. What if we want the script to loop through the DE and remove every email address in the DE from the identified list. Means remove from Auto Suppression DE by comparing any list or DE. Thanks in advance. – Piyush Rastogi Oct 23 at 5:11

Your Answer

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.