verified
Update a DataExtension folderLearn how to update a Folder in Salesforce Marketing Cloud (SFMC) with SSJS (server-side JavaScript). Code snippets include WSProxy and Core methods.
Core
var folderID = "123456";
var folder = Folder.Init(folderID);
var result = folder.Update({
"ID": folderID,
"Description": "API Updated Folder"
});
<script runat="server">
Platform.Load("core", "1");
try {
var folderID = "123456";
var folder = Folder.Init(folderID);
var result = folder.Update({
"ID": folderID,
"Description": "API Updated Folder"
});
Write(Stringify(result));
} catch(error) {
Write(Stringify(error));
}
</script>
"OK"
WSProxy
var api = new Script.Util.WSProxy();
var folderID = "123456";
var request = api.retrieve("DataFolder", ["ID", "CustomerKey"], {
Property: "ID",
SimpleOperator: "equals",
Value: folderID
})
var customerKey = request.Results[0].CustomerKey;
var result = api.updateItem("DataFolder", {
CustomerKey: customerKey,
Description: "API Updated Folder"
});
<script runat="server">
Platform.Load("core", "1");
var api = new Script.Util.WSProxy();
try {
var folderID = "123456";
var request = api.retrieve("DataFolder", ["ID", "CustomerKey"], {
Property: "ID",
SimpleOperator: "equals",
Value: folderID
})
var customerKey = request.Results[0].CustomerKey;
var result = api.updateItem("DataFolder", {
CustomerKey: customerKey,
Description: "API Updated Folder"
});
Write(Stringify(result));
} catch(error) {
Write(Stringify(error));
}
</script>
{
"Status": "OK",
"RequestID": "S0M3-GU1D-K3Y-G03SR1G4T-H3R3",
"Results": [
{
"Object": null,
"UpdateResults": null,
"ParentPropertyName": null,
"StatusCode": "OK",
"StatusMessage": "Folder updated successfully.",
"OrdinalID": 0,
"ErrorCode": 0,
"RequestID": null,
"ConversationID": null,
"OverallStatusCode": null,
"RequestType": "Synchronous",
"ResultType": null,
"ResultDetailXML": null
}
]
}
Reference
Ressources and references related to the current methods.
Official documentation
SOAP object
List of folder types