0

i'm looking for a way to automatically apply RowBasedRetention to existing data extensions, best case by using wsproxy as we are talking about quite a few. Open to other solutions than WSproxy as well, but doing it via the UI is not an option.

My script run via a cloudpage looks like this (for testing purposed I am trying to do it for a single data extensions first:

<script runat="server">  
Platform.Load("core","1.1.5");  
try{
  var mid = MidOfTheBusinessUnit;  //MID of the account
  var user = AccountUser.Retrieve({Property:"CustomerKey",SimpleOperator:"equals",Value:"MyAccountUserId"})[0].AccountUserID;  
  
  
var prox = new Script.Util.WSProxy(); 

prox.setClientId({ "ID": mid, "UserID" : user })
  
var CustomerKey = "ExternalKeyOfTheDEX", //
    DataRetentionPeriodLength = "45",
    DataRetentionPeriod = "Days",
    RowBasedRetention = true
    

var res = prox.updateItem("DataExtension", 
          {"CustomerKey":CustomerKey, 
           "DataRetentionPeriodLength":DataRetentionPeriodLength,
           "DataRetentionPeriod":DataRetentionPeriod,
           "RowBasedRetention":RowBasedRetention
          });
Write(Stringify(res));  

}catch(e){
Write(Stringify(e));
}
</script>

Once I take out the row about the RoWBasedRetention, the script works. But that is the thing, we need RowBasedRetention. I only added the two variables mid and userid as well as the line prox.setClientId({ "ID": mid, "UserID" : user }) after trying to apply Gortonington's answer here: Creating a DE with retention using WSProxy (Data Extension Manage Data Retention user permission error)

Error message when running this on a cloudpage in the parent BU: "Data retention setting cannot be updated."

Any ideas how to resolve this?

1 Answer 1

1

WSProxy emulates SOAP calls, so usually you can find a lot of examples with SOAP. -> Check the SOAP API documentation around Data Extensions:

https://developer.salesforce.com/docs/marketing/marketing-cloud/guide/creating_a_data_extension_using_web_service_api.html?q=create+data

There you'll see two more fields, my first guess would be to include them and try again:

         <Objects xsi:type="DataExtension">
            <ObjectID xsi:nil="true"/>
            <CustomerKey>12345</CustomerKey>
            <Name>12345</Name>
            <Description>12345</Description>
            <IsSendable>true</IsSendable>
            <IsTestable>false</IsTestable>
            <DataRetentionPeriodLength>48</DataRetentionPeriodLength>
            <DataRetentionPeriod>Days</DataRetentionPeriod>
            <RowBasedRetention>false</RowBasedRetention>
        <!--highlight by me -->
            <ResetRetentionPeriodOnImport>true</ResetRetentionPeriodOnImport>

            <DeleteAtEndOfRetentionPeriod>false</DeleteAtEndOfRetentionPeriod>
        <!--end highlight by me -->
            <Fields>
    ....

I'm assuming "ResetRetentionPeriodOnImport" could be the culprit. It sounds like you need to specify the import behavior as soon as you include something targeting individual rows.

2
  • I just tried and it showed the same error like OP mentioned. Also I notice that if I set "All records and data extensions" will be deleted then the API response will show RowBasedRetention: false and RowBasedRetention will equal true for "Individual Records" setting. Then Salesforce doc has inaccurate information for the property RowBasedRetention developer.salesforce.com/docs/marketing/marketing-cloud/guide/…
    – Duc Le
    Dec 7, 2022 at 8:19
  • 1
    thanks a lot. Unfortunately it does not resolve my problem. By now SF support has confirmed that there is a BUG where the SOAP call doesn’t update the RowBasedRetention. They cannot provide an ETA. So I guess there is no way at the moment.
    – Lukkinator
    Dec 8, 2022 at 16:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .