While trying to create a Data Extension with data retention using WSProxy, I am getting the following error:
The Data Extension Manage Data Retention user permission must be set in order to use the Data Extension Retention policies
I have double-checked that the above permissions are granted for my user:
Unfortunately, the error persists. Below is the code I am running on a CloudPage:
<script runat="server">
Platform.Load("core", "1.1.1");
var prox = new Script.Util.WSProxy();
try {
var name = "Retention_Test";
var de = {
Name: name,
CustomerKey: name,
Description: "Retention_Test",
Fields: [{
FieldType: "Text",
Name: "Field1",
MaxLength: 254,
IsPrimaryKey: true,
IsNillable: false,
IsRequired: true
},
{
FieldType: "Text",
Name: "Field2",
MaxLength: 254
}],
DataRetentionPeriodLength: 7,
DataRetentionPeriod: "Days",
RowBasedRetention: 0,
ResetRetentionPeriodOnImport: 1,
DeleteAtEndOfRetentionPeriod: 0
}
var res = prox.createItem("DataExtension", de);
Write(Stringify(res));
} catch(error) {
Write(Stringify(error));
}
</script>
This code works without any problems when run in Automation Studio. Unfortunately, I need to be able to run this on a CloudPage.
Any ideas will be welcome!
EDIT: I've tried impersonation via WSProxy in two ways:
prox.setClientId({"ID": Platform.Function.AuthenticatedMemberID()});
and hardcoding the ID as referenced in the documentation:
prox.setClientId({ "ID": 1xxxx378, "UserID": 1xxxx378 });
and was getting the exact same error message:
The Data Extension Manage Data Retention user permission must be set in order to use the Data Extension Retention policies