Delete a List verified

Learn how to delete (remove) a List in Salesforce Marketing Cloud (SFMC) with SSJS (server-side JavaScript). Code snippets include Core and WSProxy methods.

Core

var customerKey = "S0M3-GU1D-K3Y-G03SR1G4T-H3R3";

var lst = List.Init(customerKey);

var result = lst.Remove();
<script runat="server">

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

	try {

        var request = List.Retrieve({
            Property: "ListName",
            SimpleOperator: "equals",
            Value: "MyNewList"
        });

        var customerKey = request[0].CustomerKey;

        var lst = List.Init(customerKey);

        var result = lst.Remove();

        Write(Stringify(result));
		
	} catch(error) {

        Write(Stringify(error));
        
    }	

</script>
"OK"

WSProxy

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

var result = api.deleteItem("List", {
    ID: "12345"
});
<script runat="server">

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

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

    try {

        var request = api.retrieve("List", ["ListName", "Category", "ID"], {
            Property: "ListName",
            SimpleOperator: "equals",
            Value: "MyNewList"
        });

        var id = request.Results[0].ID;

        var result = api.deleteItem("List", {
            ID: id
        });

        Write(Stringify(result));

    } catch (error) {

        Write(Stringify(error));

    }

</script>
{
    "Status": "OK",
    "RequestID": "S0M3-GU1D-K3Y-G03SR1G4T-H3R3",
    "Results": [
        {
            "Object": null,
            "StatusCode": "OK",
            "StatusMessage": "List deleted",
            "OrdinalID": 0,
            "ErrorCode": 0,
            "RequestID": null,
            "ConversationID": null,
            "OverallStatusCode": null,
            "RequestType": "Synchronous",
            "ResultType": null,
            "ResultDetailXML": null
        }
    ]
}

Reference

Ressources and references related to the current methods.

Official documentation
SOAP object

Last Updated: