Last active
October 17, 2019 13:12
-
-
Save zuzannamj/9749722c32bd42b99e6dd59c55607850 to your computer and use it in GitHub Desktop.
Simple CloudPages app 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/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<table style="padding: 20px;"><tr><td> | |
<b>How would you like to identify the Data Extension?</b><br> | |
<form action="%%=RequestParameter('PAGEURL')=%%" method="post"> | |
<select name="DEprop"> | |
<option value="Name">Name</option> | |
<option value="CustomerKey">External Key</option> | |
</select> | |
equals | |
<input type="text" name="DEval" value="" maxlength="128"><br> | |
<input type="submit" value="Submit"> | |
</form><br><b>Folder path: </b> | |
<script runat="server"> | |
Platform.Load("core","1.1.5"); | |
var DEprop = Request.GetQueryStringParameter("DEprop"); | |
var DEval = Request.GetQueryStringParameter("DEval"); | |
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> | |
</td></tr></table> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment