Glen Mazza's Weblog

https://glenmazza.net/blog/date/20230403 Monday April 03, 2023

Changing the row retention period for SFMC data extensions

I've found that Salesforce Marketing Cloud's Email Studio UI does not allow for changing the row retention period of data extensions. Once set to 60 days, 60 days it remains. Thankfully the SFMC SOAP API can be used to alter the time period, however with one caveat: it cannot be used to introduce a row-based retention period if the data extension was not originally created with one. Unless you truly need to keep every record forever, it's useful then to always create row retention periods with new data extensions to allow them to be adjusted later. Retention periods of days, months, and years are supported.

Using SFMC's Postman Collection, I use the following SOAP call to update the row retention period for a data extension:

<?xml version="1.0" encoding="UTF-8"?>
<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://schemas.xmlsoap.org/ws/2004/08/addressing" 
    xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
    <s:Header>
        <a:Action s:mustUnderstand="1">Update</a:Action>
        <a:To s:mustUnderstand="1">https://{{et_subdomain}}.soap.marketingcloudapis.com/Service.asmx</a:To>
        <fueloauth xmlns="http://exacttarget.com">{{dne_etAccessToken}}</fueloauth>
    </s:Header>
    <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
        <UpdateRequest xmlns="http://exacttarget.com/wsdl/partnerAPI">
            <Options /> 
            <Objects xsi:type="ns1:DataExtension" xmlns:ns1="http://exacttarget.com/wsdl/partnerAPI">
                <CustomerKey>...external key of data extension...</CustomerKey> 
                <ns1:DataRetentionPeriodLength>30</ns1:DataRetentionPeriodLength>
                <ns1:DataRetentionPeriod>Days</ns1:DataRetentionPeriod>
                <ns1:ResetRetentionPeriodOnImport>true</ns1:ResetRetentionPeriodOnImport>
                <ns1:DeleteAtEndOfRetentionPeriod>true</ns1:DeleteAtEndOfRetentionPeriod>
            </Objects>
        </UpdateRequest>
    </s:Body>
</s:Envelope>

Of course, adjust length and period as desired. The Customer Key for a data extension can be found in Email Studio, where it is called the External Key:

DataExtensionCustomerKey

If the retention period was lowered, you may need to wait up to 24 hours before you see a lower rowcount for the data extension. SFMC apparently does its clearing of old records once per day.

Posted by Glen Mazza in Marketing Cloud at 03:20AM Apr 03, 2023 | Comments[2]


Calendar
« April 2023 »
Sun Mon Tue Wed Thu Fri Sat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
Today
About Me
Java Software Engineer
TightBlog project maintainer
Arlington, Virginia USA
glen.mazza at pm dot me
GitHub profile for Glen Mazza at Stack Overflow, Q&A for professional and enthusiast programmers
Blog Search


Blog article index
Navigation
About Blog
Blog software: TightBlog 4.0.0
Application Server: Tomcat
Database: MySQL
Hosted on: Linode
SSL Certificate: Let's Encrypt
Installation Instructions