Retrieve all DataExtension folders verified

Learn how to retreive all Folders in Salesforce Marketing Cloud (SFMC) with SSJS (server-side JavaScript). Code snippets include the WSProxy method.

WSProxy

var api = new Script.Util.WSProxy();
	
var req = api.retrieve("DataFolder", ["Name"], {
    Property: "ContentType",
    SimpleOperator: "equals",
    Value: "dataextension"
});

var result = [];

var results = req.Results;

for(var k in results) {
    result.push(results[k].Name);
}
<script runat="server">

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

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

	try {

        var req = api.retrieve("DataFolder", ["Name"], {
            Property: "ContentType",
            SimpleOperator: "equals",
            Value: "dataextension"
        });

        var result = [];

        var results = req.Results;

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

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

</script>
[
    "New Folder",
    "Even Newer Folder"
]

Reference

Ressources and references related to the current methods.

Official documentation
SOAP object
List of folder types

Last Updated: