0

Hello I was trying this idea from this Question. But I can't seem to make his initial idea work. Can you guys help me with this? What I am trying to do is from a data extension, i need to unsubscribe those records to all subscribers without the FTP route. Here is the code similar to the original post.


Platform.Load("core", "1");
var unsubDE = DataExtension.Init("DataExtensionName");
var data = unsubDE.Rows.Retrieve();
if(data.length > 0) {
       for (var i = 0; i < data.length; i++)
       {
           var SubId = data[i].SubscriberKey;
           var subObj = Subscriber.Init(SubId);
           var status = subObj.Unsubscribe();
               } 
              
         
      
   };
</script> ```


1 Answer 1

0

If you want to use the Subscriber function to unsub a subscriber, then you would need to use Update function instead

Try something like this:

<script runat="server">
Platform.Load("core", "1");
var unsubDE = DataExtension.Init("Data Extension external key");
var data = unsubDE.Rows.Retrieve();
if(data.length > 0) {
       for (var i = 0; i < data.length; i++)
       {
           var SubId = data[i].SubscriberKey;
           var subObj = Subscriber.Init(SubId);
           var status = subObj.Update({Status: "Unsubscribed"});
               }               
         
      
   };
</script>

SFMC documents are not always as correct as they are supposed to be.

3
  • This unfortunately did not work in unsubscribing the records in All Subscribers. Do you happen to remember what you did in your original question to achieve this? What I'm trying to achieve unsubscribing records from a data extension which is populated via an automation.
    – Ralph J
    Commented Feb 1 at 3:49
  • @RalphJ The script above did, I tested it myself. Have you managed to test it yet? Or you can try the way in the accepted answer in my original question
    – Duc Le
    Commented Feb 1 at 4:49
  • Use DE external key to initialize the DE, my Subscriber Key column name was "SubscriberKey"
    – Duc Le
    Commented Feb 1 at 4:55

You must log in to answer this question.

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