Retrieve a DataExtension folder verified

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

Core

var result = Folder.Retrieve({
    LeftOperand: {
        Property: "Name",
        SimpleOperator: "equals",
        Value: "MyFolder"
    },
    LogicalOperator: "AND",
    RightOperand: {
        Property: "ContentType",
        SimpleOperator: "equals",
        Value: "dataextension"
    }
});
<script runat="server">

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

	try {

        var result = Folder.Retrieve({
            LeftOperand: {
                Property: "Name",
                SimpleOperator: "equals",
                Value: "MyFolder"
            },
            LogicalOperator: "AND",
            RightOperand: {
                Property: "ContentType",
                SimpleOperator: "equals",
                Value: "dataextension"
            }
        });

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

</script>
[
    {
        "ID": 56789,
        "ParentFolder": {
            "ID": 1234,
            "ParentFolder": null,
            "IDSpecified": true,
            "CustomerKey": "dataextension_default",
            "Name": "Data Extensions",
            "Description": "",
            "ContentType": "dataextension",
            "IsActive": true,
            "IsActiveSpecified": true,
            "IsEditable": false,
            "IsEditableSpecified": true,
            "AllowChildren": true,
            "AllowChildrenSpecified": true,
            "ObjectID": "S0M3-GU1D-K3Y-G03SR1G4T-H3R3",
            "Client": null,
            "PartnerKey": null,
            "PartnerProperties": null,
            "CreatedDate": "0001-01-01T00:00:00.000",
            "CreatedDateSpecified": false,
            "ModifiedDate": null,
            "ModifiedDateSpecified": false,
            "Owner": null,
            "CorrelationID": null,
            "ObjectState": null,
            "IsPlatformObject": false,
            "IsPlatformObjectSpecified": false
        },
        "IDSpecified": true,
        "CustomerKey": "000000",
        "Name": "New Folder",
        "Description": "API New Folder",
        "ContentType": "dataextension",
        "IsActive": true,
        "IsActiveSpecified": true,
        "IsEditable": true,
        "IsEditableSpecified": true,
        "AllowChildren": false,
        "AllowChildrenSpecified": true,
        "ObjectID": null,
        "Client": null,
        "PartnerKey": null,
        "PartnerProperties": null,
        "CreatedDate": "0001-01-01T00:00:00.000",
        "CreatedDateSpecified": false,
        "ModifiedDate": null,
        "ModifiedDateSpecified": false,
        "Owner": null,
        "CorrelationID": null,
        "ObjectState": null,
        "IsPlatformObject": false,
        "IsPlatformObjectSpecified": false
    }
]

WSProxy

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

var categoryID = "1234";

var columns = [
    "ID",
    "CustomerKey",
    "Name",
    "Description",
    "ContentType",
    "IsActive",
    "IsEditable",
    "AllowChildren",
    "ObjectID",
    "CreatedDate",
    "ModifiedDate",
    "ParentFolder.ID",
    "ParentFolder.Name",
];

var result = api.retrieve("DataFolder", columns, {
    Property: "ID",
    SimpleOperator: "equals",
    Value: categoryID
});
<script runat="server">

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

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

	try {

        var categoryID = "1234";

        var columns = [
            "ID",
            "CustomerKey",
            "Name",
            "Description",
            "ContentType",
            "IsActive",
            "IsEditable",
            "AllowChildren",
            "ObjectID",
            "CreatedDate",
            "ModifiedDate",
            "ParentFolder.ID",
            "ParentFolder.Name",
        ];

        var result = api.retrieve("DataFolder", columns, {
            Property: "ID",
            SimpleOperator: "equals",
            Value: categoryID
        });

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

</script>
{
    "Status": "OK",
    "RequestID": "S0M3-GU1D-K3Y-G03SR1G4T-H3R3",
    "Results": [
        {
            "Name": "New Folder",
            "ParentFolder": {
                "Name": "Data Extensions",
                "ParentFolder": null,
                "ID": 3123,
                "CustomerKey": null,
                "Description": null,
                "ContentType": null,
                "IsActive": false,
                "IsEditable": false,
                "AllowChildren": false,
                "Client": null,
                "PartnerKey": null,
                "PartnerProperties": null,
                "CreatedDate": "0001-01-01T00:00:00.000",
                "ModifiedDate": null,
                "ObjectID": null,
                "Owner": null,
                "CorrelationID": null,
                "ObjectState": null,
                "IsPlatformObject": false
            },
            "ID": 1234,
            "CustomerKey": "1234",
            "Description": "API New Folder",
            "ContentType": "dataextension",
            "IsActive": true,
            "IsEditable": true,
            "AllowChildren": false,
            "Client": null,
            "PartnerKey": null,
            "PartnerProperties": null,
            "CreatedDate": "2022-10-19T08:49:23.023",
            "ModifiedDate": "2022-10-19T09:00:39.960",
            "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
List of folder types

Last Updated: