Skip to content

Commit b0c05e2

Browse files
Live publish for 10 July 2024.
2 parents 9ee1bd3 + 5dfe343 commit b0c05e2

File tree

2 files changed

+38
-25
lines changed

2 files changed

+38
-25
lines changed

powerapps-docs/developer/data-platform/long-term-retention.md

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Long-term data retention
33
description: Learn how to use retention policies to transfer data from your Microsoft Dataverse transactional database to a managed data lake for cost-efficient long-term storage.
4-
ms.date: 04/02/2024
4+
ms.date: 06/27/2024
55
ms.topic: how-to
66
author: pnghub
77
ms.author: gned
@@ -18,6 +18,26 @@ ms.custom: bap-template
1818

1919
> [!IMPORTANT]
2020
> To use all long term data retention features you must meet both of the requirements described here: [Dataverse long term data retention overview](../../maker/data-platform/data-retention-overview.md#dataverse-long-term-data-retention-overview).
21+
22+
23+
## Retrieve retained data
24+
25+
You can retrieve data that has been retained using FetchXml and [QueryExpression ](/dotnet/api/microsoft.xrm.sdk.query.queryexpression).
26+
27+
With FetchXml, set the [fetch element](fetchxml/reference/fetch.md) `datasource` attribute value to `"retained"`.
28+
29+
```xml
30+
<fetch datasource="retained">
31+
<entity name="account">
32+
<attribute name="accountId" />
33+
</entity>
34+
</fetch>
35+
```
36+
37+
With [QueryExpression ](/dotnet/api/microsoft.xrm.sdk.query.queryexpression), set the [QueryExpression.DataSource property](/dotnet/api/microsoft.xrm.sdk.query.queryexpression.datasource) to `retained`.
38+
39+
> [!NOTE]
40+
> There is currently no way to retrieve retained data using [Dataverse Web API](webapi/query-data-web-api.md).
2141
2242
## Set up a retention policy
2343

@@ -37,7 +57,7 @@ public void CreateRetentionConfig(IOrganizationService orgService)
3757
retentionConfig["uniquename"] = "ui_RetainAllClosedOpportunities";
3858
retentionConfig["statecode"] = new OptionSetValue(0);
3959
retentionConfig["statuscode"] = new OptionSetValue(10);
40-
retentionConfig["criteria"] = "<fetch version=\"1.0\" output-format=\"xml-platform\" mapping=\"logical\" distinct=\"false\"> " +
60+
retentionConfig["criteria"] = "<fetch> " +
4161
"<entity name=\"opportunity\"> " +
4262
"<attribute name=\"name\" /> " +
4363
"<attribute name=\"statecode\" />" +
@@ -88,7 +108,7 @@ Accept: application/json
88108
"uniquename": "ui_RetainAllClosedOpportunities",
89109
"statuscode": 10,
90110
"criteria":
91-
"<fetch version=\"1.0\" output-format=\"xml-platform\" mapping=\"logical\" distinct=\"false\">
111+
"<fetch>
92112
<entity name=\"opportunity\">
93113
<attribute name=\"name\" />
94114
<attribute name=\"statecode\" />
@@ -302,7 +322,7 @@ This code sample shows a simple query to return all active retention policies fo
302322
public EntityCollection GetActivePolicies(IOrganizationService orgService)
303323
{
304324
string fetchXml = @"
305-
<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>
325+
<fetch>
306326
<entity name='retentionconfig'>
307327
<attribute name='retentionconfigid' />
308328
<attribute name='name' />
@@ -342,7 +362,7 @@ public EntityCollection GetActivePolicies(IOrganizationService orgService)
342362
This code sample illustrates using a FetchXML statement to retrieve all paused retention policies for an email.
343363

344364
```xml
345-
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
365+
<fetch>
346366
<entity name="retentionconfig">
347367
<attribute name="retentionconfigid" />
348368
<attribute name="name" />
@@ -363,7 +383,7 @@ This code sample illustrates using a FetchXML statement to retrieve all paused r
363383
This code sample shows how to use a FetchXML statement to retrieve all retention operations for a retention policy.
364384

365385
```xml
366-
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
386+
<fetch>
367387
<entity name="retentionoperation">
368388
<attribute name="retentionoperationid" />
369389
<attribute name="name" />
@@ -375,7 +395,10 @@ This code sample shows how to use a FetchXML statement to retrieve all retention
375395
<attribute name="criteria" />
376396
<order attribute="name" descending="false" />
377397
<filter type="and">
378-
<condition attribute="retentionconfigid" operator="eq" uiname="All closed opportunities" uitype="retentionconfig" value="{35CC1317-20B7-4F4F-829D-5D9D5D77F763}" />
398+
<condition
399+
attribute="retentionconfigid"
400+
operator="eq"
401+
value="{35CC1317-20B7-4F4F-829D-5D9D5D77F763}" />
379402
</filter>
380403
</entity>
381404
</fetch>
@@ -384,7 +407,7 @@ This code sample shows how to use a FetchXML statement to retrieve all retention
384407
This code sample shows a FetchXML statement that retrieves details for a retention operation.
385408

386409
```xml
387-
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
410+
<fetch>
388411
<entity name="retentionoperationdetail">
389412
<attribute name="retentionoperationdetailid" />
390413
<attribute name="name" />
@@ -396,7 +419,7 @@ This code sample shows a FetchXML statement that retrieves details for a retenti
396419
<attribute name="entitylogicalname" />
397420
<order attribute="name" descending="false" />
398421
<filter type="and">
399-
<condition attribute="retentionoperationid" operator="eq" uitype="retentionoperation" value="{35CC1317-20B7-4F4F-829D-5D9D5D77F763}"/>
422+
<condition attribute="retentionoperationid" operator="eq" value="{35CC1317-20B7-4F4F-829D-5D9D5D77F763}"/>
400423
</filter>
401424
</entity>
402425
</fetch>
@@ -405,7 +428,7 @@ This code sample shows a FetchXML statement that retrieves details for a retenti
405428
This code sample illustrates the FetchXML statement that retrieves details about a failure that occurred during a retention operation.
406429

407430
```xml
408-
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
431+
<fetch>
409432
<entity name="retentionfailuredetail">
410433
<attribute name="retentionfailuredetailid" />
411434
<attribute name="name" />

powerapps-docs/maker/data-platform/data-retention-view.md

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -34,34 +34,24 @@ For more information about creating and editing Dataverse security roles, go to
3434
1. Open the view you want. From the view, select **Edit filters**.
3535
1. Select **Change to retained data**.
3636
:::image type="content" source="media/data-retention-advanced-find.png" alt-text="Select change to retained data on the edit filter pane.":::
37+
38+
> [!NOTE]
39+
> This changes the [fetch element](../../developer/data-platform/fetchxml/reference/fetch.md) `datasource` attribute value to `"retained"`.
40+
3741
1. Select the tables and search filters you want, and then select **Apply**. The retained data is displayed in the read-only grid.
3842
:::image type="content" source="media/data-retention-advanced-find-results.png" alt-text="Advanced find query results displaying retained case records":::
3943
If you need to retrieve long term data from multiple related tables, such as the account table, which has an associated retained case table, first use advanced find retrieve the retained case row. Then use the `Casenumber` column and use advanced find to retrieve the account row that contains the case number.
4044

4145
More information: [Advanced find in model-driven apps](../../user/advanced-find.md)
4246

43-
## View retained data using using FetchXml
44-
In order to fetch the retained data for a table, specify the `datasource="retained"` in the FetchXml.
45-
46-
Example:
47-
```xml
48-
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="true" no-lock="false" datasource="retained">
49-
<entity name="opportunity">
50-
<attribute name="opportunityid"></attribute>
51-
</entity>
52-
</fetch>
53-
```
54-
55-
More information: [Use FetchXml to retrieve data](/power-apps/developer/data-platform/fetchxml/retrieve-data?tabs=sdk)
56-
5747
## View retained data using a flow
5848

5949
Create a Power Automate cloud flow to create an Excel file of the retained data from a FetchXML query and send as an email attachment. More information: [Create a cloud flow to view Dataverse long term retained data](/power-automate/dataverse/data-retention-flow)
6050

6151
> [!NOTE]
6252
> If the retained data includes attachments from the annotation table, the returned value is a base64 representation of the file. Large files might cause the cloud flow action to [time-out](/power-automate/limits-and-config#timeout) or to exceed its output [message size limit](/power-automate/limits-and-config#message-size).
6353
>
64-
> To workaround this behavior, use the Web API to perform the export action [ExportRetainedData](/power-apps/developer/data-platform/webapi/reference/exportretaineddata?view=dataverse-latest&preserve-view=true) using Azure Functions or other custom development options.
54+
> To workaround this behavior, use the `ExportRetainedData` message Web API to [ExportRetainedData action](/power-apps/developer/data-platform/webapi/reference/exportretaineddata) or SDK for .NET using Azure Functions or other custom development options.
6555
6656
## Limitations for retrieval of retained data
6757

0 commit comments

Comments
 (0)