|
| 1 | +--- |
| 2 | +title: "Sample: Query and detect metadata changes (Common Data Service) | Microsoft Docs" # Intent and product brand in a unique string of 43-59 chars including spaces |
| 3 | +description: "This sample shows how to query and detect metadata changes" # 115-145 characters including spaces. This abstract displays in the search result. |
| 4 | +ms.custom: "" |
| 5 | +ms.date: 05/08/2020 |
| 6 | +ms.reviewer: "nabuthuk" |
| 7 | +ms.service: powerapps |
| 8 | +ms.topic: "article" |
| 9 | +author: "JimDaly" # GitHub ID |
| 10 | +ms.author: "jdaly" # MSFT alias of Microsoft employees only |
| 11 | +manager: "ryjones" # MSFT alias of manager or PM counterpart |
| 12 | +search.audienceType: |
| 13 | + - developer |
| 14 | +search.app: |
| 15 | + - PowerApps |
| 16 | + - D365CE |
| 17 | +--- |
| 18 | + |
| 19 | +# Query and detect metadata changes |
| 20 | + |
| 21 | + |
| 22 | +This sample shows how to retrieve and detect metadata changes using [RetrieveMetadataChangeRequest](https://docs.microsoft.com/dotnet/api/microsoft.xrm.sdk.messages.retrievemetadatachangesrequest?view=dynamics-general-ce-9) method. You can download the sample from [here](https://github.com/microsoft/PowerApps-Samples/tree/master/cds/orgsvc/C%23/MetadataQuery). |
| 23 | + |
| 24 | +## How to run this sample |
| 25 | + |
| 26 | +[!include[cc-how-to-run-samples](../../includes/cc-how-to-run-samples.md)] |
| 27 | + |
| 28 | +## What this sample does |
| 29 | + |
| 30 | +The `RetrieveMetadataChangeRequest` message is intended to be used in a scenario where it contains the data that is needed to retrieve a collection of metadata records that satisfy the specified criteria. The [RetrieveMetadataChangesResponse](https://docs.microsoft.com/dotnet/api/microsoft.xrm.sdk.messages.retrievemetadatachangesresponse?view=dynamics-general-ce-9) returns a timestamp value that can be used with this request at a later time to return information about how metadata has changed since the last request. |
| 31 | + |
| 32 | +## How this sample works |
| 33 | + |
| 34 | +To simulate the scenario described in [What this sample does](#what-this-sample-does), the sample will do the following: |
| 35 | + |
| 36 | +### Setup |
| 37 | + |
| 38 | +Checks for the current version of the org. |
| 39 | + |
| 40 | +### Demonstrate |
| 41 | + |
| 42 | +1. The `MetadataFilterExpression` method creates the filter expression to limit entities returned to non-intersect, user-owned entities not found in the list of excluded entities. |
| 43 | +2. The `MetadataConditionExpression` method returns the optionset attributes. |
| 44 | +3. The `MetadataPropertiesExpression` method limits the properties to be included with the attributes. |
| 45 | +4. The `LabelQueryExpression` method limits the labels returned to only those for user's preferred language. |
| 46 | +5. The `RetrieveMetadataChangeRequest` method retrieves the metadata for the query. |
| 47 | + |
| 48 | + |
| 49 | +### Clean up |
| 50 | + |
| 51 | +Display an option to delete the sample data that is created in [Setup](#setup). The deletion is optional in case you want to examine the entities and data created by the sample. You can manually delete the records to achieve the same result. |
0 commit comments