Retrieve the status of a Subscriber verified

Learn how to retrieve the status of a Subscriber in Salesforce Marketing Cloud (SFMC) with SSJS (server-side JavaScript). Code snippets include the WSProxy method.

WSProxy

var api = new Script.Util.WSProxy();

var cols = [
    "ObjectID", 
    "SubscriberID",
    "Client.ID",
    "CurrentStatus",
    "PreviousStatus",
    "CreatedDate",
    "SubscriberKey",
    "ReasonUnsub"
];

var filter = {
    Property: "CurrentStatus",
    SimpleOperator: "equals",
    Value: "Normal"
}

var opts = {
    BatchSize: 300
};

var props = {
    QueryAllAccounts: false
};

var result = api.retrieve("SubscriberStatusEvent", cols, filter, opts, props);
<script runat="server">

    Platform.Load("core", "1");

    var api = new Script.Util.WSProxy();

    try {

        var cols = [
            "ObjectID", 
            "SubscriberID",
            "Client.ID",
            "CurrentStatus",
            "PreviousStatus",
            "CreatedDate",
            "SubscriberKey",
            "ReasonUnsub"
        ];

        var filter = {
            LeftOperand: {
                Property: "CurrentStatus",
                SimpleOperator: "equals",
                Value: "Normal"
            },
            LogicalOperator: "AND",
            RightOperand: {
                Property: "CreatedDate",
                SimpleOperator: "greaterThan",
                Value: "2022-12-24"
            }
        }

        var opts = {
            BatchSize: 300
        };

        var props = {
            QueryAllAccounts: false
        };

        var result = [],
            moreData = true,
            reqID = data = null;

        while(moreData) {

            moreData = false;

            if(reqID) props.ContinueRequest = reqID;

            var req = api.retrieve("SubscriberStatusEvent", cols, filter, opts, props);

            if (req) {

                moreData = req.HasMoreRows;
                reqID = req.RequestID;

                var results = req.Results;

                for (var k in results) {
                    var status = results[k];
                    result.push(status);
                }

            }
        }

        Write(Stringify(result));

    } catch (error) {

        Write(Stringify(error));

    }

</script>
[
    {
        "Type": "SubscriberStatusEvent",
        "Properties": [
            {
                "Name": "SubscriberID",
                "Value": "12345678"
            },
            {
                "Name": "CurrentStatus",
                "Value": "normal"
            },
            {
                "Name": "PreviousStatus",
                "Value": "held"
            },
            {
                "Name": "SubscriberKey",
                "Value": "S0M3-GU1D-K3Y-G03SR1G4T-H3R3"
            },
            {
                "Name": "ReasonUnsub",
                "Value": ""
            }
        ],
        "Client": {
            "ID": 100000000,
            "ClientID1": 0,
            "PartnerClientKey": null,
            "UserID": 0,
            "PartnerUserKey": null,
            "CreatedBy": 0,
            "ModifiedBy": 0,
            "EnterpriseID": 0,
            "CustomerKey": null,
            "CustomerID": null
        },
        "PartnerKey": null,
        "PartnerProperties": null,
        "CreatedDate": "2024-01-01T05:10:52.082",
        "ModifiedDate": null,
        "ID": 0,
        "ObjectID": "S0M3-GU1D-K3Y-G03SR1G4T-H3R3",
        "CustomerKey": null,
        "Owner": null,
        "CorrelationID": null,
        "ObjectState": null,
        "IsPlatformObject": false
    }
]

WARNING

Please mind that BatchSize option for this WSProxy retrieval is broken and will always default to 2500.

Statuses

Here is the list of available statuses for CurrentStatus and PreviousStatus properties:

  • Normal
  • Held
  • Unsub

Reference

Ressources and references related to the current methods.

Official documentation
SOAP object

Last Updated: