I'm trying to loop through all folders found in the parent folder and show the folder names. This is what I have so far but it doesn't work (I just get an error page)
<script runat="server">
Platform.Load("core", "1.1.5");
var parentFolderID = 327786;
var prox = new Script.Util.WSProxy();
var cols = ["Name", "ContentType", "ID", "CustomerKey"];
var filter = {
LeftOperand: {
Property: "ParentFolder.ID",
SimpleOperator: "equals",
Value: parentFolderID
},
LogicalOperator: "AND",
RightOperand: {
Property: "ContentType",
SimpleOperator: "equals",
Value: 'dataextension'
}
};
var data = prox.retrieve("DataFolder", cols, filter);
for (var i=0; i< data.length; i++) {
Write(data.Results[i].Name+"<br>");
};
</script>
If I don't write it in a loop and write it out line by line like the code below, the Folder Name is displayed and this is the only way I can get it to work so far:
Write(data.Results[0].Name);
this however isn't going to work for the scenario that I want, which is looping through all subfolders and displaying the name
I also know that there ARE results that exist because this is the example output
{
"Status": "OK",
"RequestID": "4ab563b5-9195-4568-905c-cab6d963c685",
"Results": [{
"ParentFolder": null,
"Name": "2020",
"Description": null,
"ContentType": "dataextension",
"IsActive": false,
"IsEditable": false,
"AllowChildren": false,
"Client": null,
"PartnerKey": null,
"PartnerProperties": null,
"CreatedDate": "0001-01-01T00:00:00.000",
"ModifiedDate": null,
"ID": 328162,
"ObjectID": null,
"CustomerKey": "",
"Owner": null,
"CorrelationID": null,
"ObjectState": null,
"IsPlatformObject": false
}, {
"ID": 342627,
"ContentType": "dataextension",
"Name": "2021",
"CustomerKey": "",
"ParentFolder": null,
"Description": 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
}],
"HasMoreRows": false
}
And when I wrap the loop with a try/catch this is the message I get. Note that the "2020" and "2021" are the folder names that I wanted to grab
2020
2021
{"message":"\"i[i]\" is not defined","description":"Jint.JintException: \"i[i]\" is not defined - from Jint\r\n\r\n"}