1

I'm building a custom prefs centre that updates Publication Lists via WSProxy. It includes an "Unsubscribe from all emails" option that updates the status on AllSubscribers to unsubscribed. So far, all working as expected.

When the "Unsubscribe from all emails" is unchecked, I have implemented the following code, with the intent to reactivate the subscriber:

            var prox = new Script.Util.WSProxy();
            var sub = {
                SubscriberKey: subscriber_key,
                EmailAddress: email,
                Lists: [{
                    ID: all_subscribers_list_id,
                    Status: "Active"
                }]
            };
            var options = { 
                SaveOptions: [{
                  PropertyName: "*",
                  SaveAction: "UpdateAdd"
                }]
            };
            var result = prox.createItem("Subscriber", sub, options);

This API call is returning a successful result, including the correct ListID for AllSubscribers, however reviewing the Subscriber in Email Studio indicates they are still unsubscribed.

What am I missing?

1 Answer 1

2

To update a subscriber status in All Subscribers List, you would need to specify the status property in Subscriber object.

I would do this:

<script runat="server">
Platform.Load('core', '1.1.1');
var prox = new Script.Util.WSProxy();

var sub = {
    SubscriberKey: "Your sub key",
    EmailAddress: "Your sub email",
    Status: "Active"

};
var options = { 
    SaveOptions: [{
        PropertyName: "*",
        SaveAction: "UpdateAdd"
    }]
};

var resp = prox.createItem("Subscriber", sub, options);
</script>

To update the subscriber status in in All Subscribers List and Publication List at the same time, you would need to have the status in both subscriber itself and the Lists property.

<script runat="server">
Platform.Load('core', '1.1.1');
var prox = new Script.Util.WSProxy();

var sub = {
    SubscriberKey: "Your sub key",
    EmailAddress: "Your sub email",
    Status: "Active",
    Lists: [{
        ID: "Your Publication List ID",
        Status: "Active"
    }]

};
var options = { 
    SaveOptions: [{
        PropertyName: "*",
        SaveAction: "UpdateAdd"
    }]
};

var resp = prox.createItem("Subscriber", sub, options);
</script>
1
  • Perfect, thank you. I had not understood the difference between List status and Subscriber status. Commented Mar 7, 2023 at 1:53

You must log in to answer this question.

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