Skip to content

Instantly share code, notes, and snippets.

@zuzannamj
Last active October 17, 2019 13:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zuzannamj/6d0c9a2122528a31f6ce0e4687922d1e to your computer and use it in GitHub Desktop.
Save zuzannamj/6d0c9a2122528a31f6ce0e4687922d1e to your computer and use it in GitHub Desktop.
Script for finding a Data Extension and it's folder path using SSJS. Read more here: https://sfmarketing.cloud/2019/10/14/find-a-data-extension-and-its-folder-path-using-ssjs/
<script runat="server">
Platform.Load("core","1.1.5");
var DEprop = //use either "Name" or "Customer Key"
var DEval = //provide either the Name or External Key
var FindDE = DataExtension.Retrieve({Property:DEprop,SimpleOperator:"equals",Value:DEval});
var FolderID = FindDE[0].CategoryID;
var DEname = FindDE[0].Name;
var list = [];
list.push(DEname);
var path = function(id) {
if (id> 0) {
var results = Folder.Retrieve({Property:"ID",SimpleOperator:"equals",Value:id});
list.unshift(results [0].Name);
return path(results[0].ParentFolder.ID);
} else {
return id;
}
};
path(FolderID);
Write(list.join("> "));
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment