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]

Comments
Hi I used your exact code in postman. Only changed the Data extension key, did not included the actual key. I am getting a bad header error: Bad Request - Invalid Header

HTTP Error 400. The request has an invalid header name.

here's my code: Update https://{{et_subdomain}}.soap.marketingcloudapis.com/Service.asmx {{dne_etAccessToken}} CustomUpload-1492285303 30 Days true true

Posted by venkat reddy at 06:37PM Sep 19, 2023

Hi Venkat, your rather generic error message suggests that your problem is not specific to this particular request, but might well happen were you to issue any type of SOAP request using SFMC's SOAP API. You might wish to first confirm that other SOAP requests (such as querying a list or subscriber's details using the default calls provided in the SFMC Postman collection) are working, and get help from community boards if that is not the case.

Posted by Glen Mazza at 03:24AM Nov 23, 2023

Post a Comment:

Calendar
« March 2024
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
31
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