Retrieve a Data Extension verified

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

Core

var result = DataExtension.Retrieve({
    Property: "Name",
    SimpleOperator: "equals",
    Value: "Customers"
});
<script runat="server">

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

	try {

        var result = DataExtension.Retrieve({
            Property: "Name",
            SimpleOperator: "equals",
            Value: "Customers"
        });

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

</script>
[
    {
        "Name": "MyDataExtension",
        "Description": "",
        "IsSendable": false,
        "IsTestable": false,
        "CategoryID": 1234,
        "IsPlatformObject": false,
        "CustomerKey": "S0M3-GU1D-K3Y-G03SR1G4T-H3R3",
        "CreatedDate": "2020-03-28T14:18:40.313",
        "ModifiedDate": "2022-10-14T09:03:28.290",
        "ObjectID": "S0M3-GU1D-K3Y-G03SR1G4T-H3R3",
        "Client": {
            "ID": 100000000
        },
        "Status": "None",
        "PartnerKey": ""
    }
]

WSProxy

var cols = [
    "ObjectID",
    "PartnerKey",
    "CustomerKey",
    "Name",
    "CreatedDate",
    "ModifiedDate",
    "Client.ID",
    "Description",
    "IsSendable",
    "IsTestable",
    "SendableDataExtensionField.Name",
    "SendableSubscriberField.Name",
    "Template.CustomerKey",
    "CategoryID",
    "Status",
    "IsPlatformObject",
    "DataRetentionPeriodLength",
    "DataRetentionPeriodUnitOfMeasure",
    "RowBasedRetention",
    "ResetRetentionPeriodOnImport",
    "DeleteAtEndOfRetentionPeriod",
    "RetainUntil",
    "DataRetentionPeriod"
];

var result = api.retrieve("DataExtension", cols, {
    Property: "Name",
    SimpleOperator: "equals",
    Value: "MyDataExtension"
});
<script runat="server">

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

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

	try {

        var cols = [
            "ObjectID",
            "PartnerKey",
            "CustomerKey",
            "Name",
            "CreatedDate",
            "ModifiedDate",
            "Client.ID",
            "Description",
            "IsSendable",
            "IsTestable",
            "SendableDataExtensionField.Name",
            "SendableSubscriberField.Name",
            "Template.CustomerKey",
            "CategoryID",
            "Status",
            "IsPlatformObject",
            "DataRetentionPeriodLength",
            "DataRetentionPeriodUnitOfMeasure",
            "RowBasedRetention",
            "ResetRetentionPeriodOnImport",
            "DeleteAtEndOfRetentionPeriod",
            "RetainUntil",
            "DataRetentionPeriod"
        ];

        var result = api.retrieve("DataExtension", cols, {
            Property: "Name",
            SimpleOperator: "equals",
            Value: "MyDataExtension"
        });

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

</script>
{
    "Status": "OK",
    "RequestID": "S0M3-GU1D-K3Y-G03SR1G4T-H3R3",
    "Results": [
        {
            "CustomerKey": "S0M3-GU1D-K3Y-G03SR1G4T-H3R3",
            "Name": "MyDataExtension",
            "Description": "",
            "IsSendable": false,
            "IsTestable": false,
            "SendableDataExtensionField": null,
            "SendableSubscriberField": null,
            "Template": null,
            "DataRetentionPeriodLength": 0,
            "DataRetentionPeriodUnitOfMeasure": 0,
            "RowBasedRetention": false,
            "ResetRetentionPeriodOnImport": false,
            "DeleteAtEndOfRetentionPeriod": false,
            "RetainUntil": "",
            "Fields": null,
            "DataRetentionPeriod": "Days",
            "CategoryID": 1234,
            "Status": "None",
            "Client": {
                "ID": 100000000,
                "ClientID1": 0,
                "PartnerClientKey": null,
                "UserID": 0,
                "PartnerUserKey": null,
                "CreatedBy": 0,
                "ModifiedBy": 0,
                "EnterpriseID": 0,
                "CustomerKey": null,
                "CustomerID": null
            },
            "PartnerKey": "",
            "PartnerProperties": null,
            "CreatedDate": "2020-03-28T14:18:40.312",
            "ModifiedDate": "2022-10-14T09:03:28.289",
            "ID": 0,
            "ObjectID": "S0M3-GU1D-K3Y-G03SR1G4T-H3R3",
            "Owner": null,
            "CorrelationID": null,
            "ObjectState": null,
            "IsPlatformObject": false
        }
    ],
    "HasMoreRows": false
}

Reference

Ressources and references related to the current methods.

Official documentation
SOAP object

Last Updated: