I'm trying to do it this way, but I'm getting 500 error


var @SubscriberKey, @ListID, @ListType

set @SubscriberKey = "example"
set @ListID= 123 
SET @ListType= "Publication List"

IF Not Empty(@SubscriberKey) THEN

set @UpsertData = UpsertData("_ListSubscribers",3,"SubscriberKey", @SubscriberKey, "ListID", @ListID, "ListType", @ListType, "Status", "Active")
OUTPUTLINE(CONCAT("<br>Rows updated: ",@UpsertData))


  • You can't update dataviews, you would need to make an API call to update this
    – EazyE
    Jul 9 '20 at 19:48

If you are looking to just change status for subscriber inside of a list, you will need to use SFMC SSJS Core functions or WSProxy. You can use the AMPScript API functions, but this is highly inefficient and requires a ton of unnecessary processing.

For Core, you would look at using List.Subscribers:

For making a user active, you would want to do List.Subscribers.Update like so:

var myList = List.Init("myList");
var status = myList.Subscribers.Update("mySubscriberKey","Active");

For unsubscribing, you can use the Core function List.Subscribers.Unsubscribe like so:

var myList = List.Init("myList");
var status = myList.Subscribers.Unsubscribe("mySubscriberKey");

One note on this is that if you are trying to create an unsub event (tying the unsubscribe to a job with reason, etc.) then this is not your preferred path. You will want to use the 'LogUnsubEvent' API call. This is best accomplished via WSProxy:

<script runat="server">
try {
    var prox = new Script.Util.WSProxy();

    /* Set ClientID */
    prox.setClientId({ "ID": mid}); //Impersonates the BU

    var props = [
       { Name: "SubscriberKey", Value: "sample@sample.com" },
       { Name: "EmailAddress", Value: "sample@sample.com" },
       { Name: "JobID", Value: 18099 },
       { Name: "ListID", Value: 8675309 },
       { Name: "BatchID", Value: 0 }
    var data = prox.execute(props, "LogUnsubEvent");
} catch(e) {

Here is an article I wrote about doing it.

That being said, if you are looking to do the changes in bulk, then WSProxy is the better way to go as it has batch options.

<script runat="server">    

  var prox = new Script.Util.WSProxy();
  var subArr = [];
  var myArr = //my Array containing the sub info needed to be changed
  for(i=1;i<myArr;i++) {
    //iterate through your 'myArr' to grab the correct info and insert into below
    var subObj = {
        SubscriberKey: subkey,
        EmailAddress: email,
        Lists: [{
            ID: '12345',
            Status: 'Active'
  var options = { 
    SaveOptions: [{
      PropertyName: "*",
      SaveAction: "UpdateAdd"

 var resp = prox.createBatch("Subscriber", subArr, options);

If you desperately want to do it via AMPScript API functionality, I would look at this article by Zuzanna that details out the LogUnsubEvent calls for you in both AMPScript and SSJS.

  • 1
    Wow... Thanks Gregory for sharing the detailed knowledge on possibilities of list updation along with when to use them... Very helpful Jul 11 '20 at 5:00

There are many ways you can achieve this. But due to the simplicity and I prefer to use WSProxy method as below.

<script runat="server">

//Making use of Web-socket Proxy
var prox = new Script.Util.WSProxy();
var options = {SaveOptions: [{'PropertyName': '*', SaveAction: 'UpdateAdd'}]};

//Similar to RequestParameter in AMPscript to get values from Form submitted
var sub_key = Platform.Request.GetFormField('subkey')
var email = Platform.Request.GetFormField('email')

function unsub() {
prox.setClientId({ "ID": "10966194" }); //Setting MID
var props = { 
                SubscriberKey: sub_key,
                EmailAddress: email,
                Lists: [{ID: '1753',    //Setting your LIST_ID
                        Status: 'Unsubscribed' // to unsub = "Unsubscribed" to subscribe = "Active"
var data = prox.updateItem("Subscriber", props, options);

return data.Results[0].StatusCode;

unsub(); //Run the above custom function

Received value subkey = <ctrl:var name=sub_key /> <br/><br/>
Hi User, your email address <ctrl:var name=email /> has been unsubscribed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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