Skip to content

Commit e134b19

Browse files
authored
Merge pull request #926 from MicrosoftDocs/master
publishing changes to metadata query topics
2 parents 9dea9c1 + 00b91c2 commit e134b19

File tree

3 files changed

+36
-68
lines changed

3 files changed

+36
-68
lines changed

powerapps-docs/developer/common-data-service/webapi/query-metadata-web-api.md

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: "Query metadata using the Web API (Common Data Service for Apps) | Microsoft Docs"
33
description: "The capability to query system metadata is available using the Web API as well as using the organization service by using RetrieveMetadataChangesRequest"
44
ms.custom: ""
5-
ms.date: 10/31/2018
5+
ms.date: 11/04/2018
66
ms.reviewer: ""
77
ms.service: "crm-online"
88
ms.suite: ""
@@ -23,8 +23,11 @@ search.app:
2323
---
2424
# Query metadata using the Web API
2525

26-
Because Common Data Service for Apps is a metadata-driven application, developers may need to query the system metadata at run-time to adapt to how an organization has been configured. This capability is available using the Web API as well as using the organization service by using the <xref:Microsoft.Xrm.Sdk.Messages.RetrieveMetadataChangesRequest> and the classes of the <xref:Microsoft.Xrm.Sdk.Metadata.Query> namespace. The Web API allows for querying metadata but does not provide the ability to detect changes to metadata from a point in time.
27-
26+
Because Common Data Service for Apps is a metadata-driven application, developers may need to query the system metadata at run-time to adapt to how an organization has been configured. This capability uses a RESTful query style.
27+
28+
> [!NOTE]
29+
> You can also construct a query using an object-based style using the <xref href="Microsoft.Dynamics.CRM.EntityQueryExpression?text=EntityQueryExpression ComplexType" /> with the <xref href="Microsoft.Dynamics.CRM.RetrieveMetadataChanges?text=RetrieveMetadataChanges Function" />. This function allows for capturing changes to metadata between two periods of time as well as returning a limited set of metadata defined by a query you specify.
30+
2831
<a name="bkmk_QueryingEntityMetadata"></a>
2932

3033
## Querying the EntityMetadata entity type
@@ -85,7 +88,7 @@ There are no limits on the number of metadata entities that will be returned in
8588

8689
## Use enum types in $filter operations
8790

88-
When you need to filter metadata entities based on the value of a property that uses an enumeration, you must include the namespace of the enumeration before the string value. Enum types are used as property values only in metadata entities and complex types. For example, if you need to filter entities based on the OwnershipType property, which uses the <xref href="Microsoft.Dynamics.CRM.OwnershipTypes?text=OwnershipTypes EnumType" />, you can use the following `$filter` to return only those entities that are UserOwned.
91+
When you need to filter metadata entities based on the value of a property that uses an enumeration, you must include the namespace of the enumeration before the string value. Enum types are used as property values only in metadata entities and complex types. For example, if you need to filter entities based on the `OwnershipType` property, which uses the <xref href="Microsoft.Dynamics.CRM.OwnershipTypes?text=OwnershipTypes EnumType" />, you can use the following `$filter` to return only those entities that are UserOwned.
8992

9093
```http
9194
GET [Organization URI]/api/data/v9.0/EntityDefinitions?$select=LogicalName&$filter=OwnershipType eq Microsoft.Dynamics.CRM.OwnershipTypes'UserOwned'
@@ -96,7 +99,7 @@ GET [Organization URI]/api/data/v9.0/EntityDefinitions?$select=LogicalName&$filt
9699
## Use complex types in $filter operations
97100

98101
When you need to filter metadata entities based on the value of a property that uses a complex type, you must include the path to the underlying primitive type. Complex types are used as property values only in metadata entities. For example, if you need to filter entities based on the CanCreateAttributes property, which uses the <xref href="Microsoft.Dynamics.CRM.BooleanManagedProperty?text=BooleanManagedProperty ComplexType" />, you can use the following `$filter` to return only those entities that have a `Value` of `true`.
99-
102+
100103
```http
101104
GET [Organization URI]/api/data/v9.0/EntityDefinitions?$select=LogicalName&$filter=CanCreateAttributes/Value eq true
102105
```
@@ -107,17 +110,17 @@ This pattern works with <xref href="Microsoft.Dynamics.CRM.BooleanManagedPropert
107110

108111
## Querying EntityMetadata attributes
109112

110-
You can query entity attributes in the context of an entity by expanding the Attributes collection-valued navigation property but this will only include the common properties available in the <xref href="Microsoft.Dynamics.CRM.AttributeMetadata?text=AttributeMetadata EntityType" /> which all attributes share. For example the following query will return the LogicalName of the entity and all the expanded Attributes which have an AttributeType value equal to the <xref href="Microsoft.Dynamics.CRM.AttributeTypeCode?text=AttributeTypeCode EnumType" /> value of Picklist.
113+
You can query entity attributes in the context of an entity by expanding the `Attributes` collection-valued navigation property but this will only include the common properties available in the <xref href="Microsoft.Dynamics.CRM.AttributeMetadata?text=AttributeMetadata EntityType" /> which all attributes share. For example the following query will return the `LogicalName` of the entity and all the expanded Attributes which have an `AttributeType` value equal to the <xref href="Microsoft.Dynamics.CRM.AttributeTypeCode?text=AttributeTypeCode EnumType" /> value of `Picklist`.
111114

112115
<a name="bkmk_queryAttributesexample"></a>
113116

114117
```http
115118
GET [Organization URI]/api/data/v9.0/EntityDefinitions(LogicalName='account')?$select=LogicalName&$expand=Attributes($select=LogicalName;$filter=AttributeType eq Microsoft.Dynamics.CRM.AttributeTypeCode'Picklist')
116119
```
117120

118-
But you can’t include the OptionSet or GlobalOptionSet collection-valued navigation properties that <xref href="Microsoft.Dynamics.CRM.PicklistAttributeMetadata?text=PicklistAttributeMetadata EntityType" /> attributes have within the `$select` filter of this query.
121+
But you can’t include the `OptionSet` or `GlobalOptionSet` collection-valued navigation properties that <xref href="Microsoft.Dynamics.CRM.PicklistAttributeMetadata?text=PicklistAttributeMetadata EntityType" /> attributes have within the `$select` filter of this query.
119122

120-
In order to retrieve the properties of a specific type of attribute you must cast the Attributes collection-valued navigation property to the type you want. The following query will return only the PicklistAttributeMetadata attributes and will include the LogicalName as well as expanding the OptionSet and GlobalOptionSet collection-valued navigation properties
123+
In order to retrieve the properties of a specific type of attribute you must cast the `Attributes` collection-valued navigation property to the type you want. The following query will return only the <xref href="Microsoft.Dynamics.CRM.PicklistAttributeMetadata?text=PicklistAttributeMetadata EntityType" /> attributes and will include the `LogicalName` as well as expanding the `OptionSet` and `GlobalOptionSet` collection-valued navigation properties
121124

122125
```http
123126
GET [Organization URI]/api/data/v9.0/EntityDefinitions(LogicalName='account')/Attributes/Microsoft.Dynamics.CRM.PicklistAttributeMetadata?$select=LogicalName&$expand=OptionSet,GlobalOptionSet
@@ -126,8 +129,8 @@ GET [Organization URI]/api/data/v9.0/EntityDefinitions(LogicalName='account')/At
126129
> [!NOTE]
127130
> Despite the fact that the `OptionSet` and `GlobalOptionSet` collection-valued navigation properties are defined within <xref href="Microsoft.Dynamics.CRM.EnumAttributeMetadata?text=EnumAttributeMetadata EntityType" />, you cannot cast the attributes to this type. This means that if you want to filter on other types which also inherit these properties (see [Entity types that inherit from EnumAttributeMetadata](/dynamics365/customer-engagement/web-api/enumattributemetadata?view=dynamics-ce-odata-9#Derived_Types) ), you must perform separate queries to filter for each type.
128131
129-
Another example of this is accessing the Precision property available in <xref href="Microsoft.Dynamics.CRM.MoneyAttributeMetadata?text=MoneyAttributeMetadata EntityType" /> and <xref href="Microsoft.Dynamics.CRM.DecimalAttributeMetadata?text=DecimalAttributeMetadata EntityType" /> attributes. To access this property you must cast the attributes collection either as `MoneyAttributeMetadata` or `DecimalAttributeMetadata`. An example showing casting to `MoneyAttributeMetadata` is shown here.
130-
132+
Another example of this is accessing the `Precision` property available in <xref href="Microsoft.Dynamics.CRM.MoneyAttributeMetadata?text=MoneyAttributeMetadata EntityType" /> and <xref href="Microsoft.Dynamics.CRM.DecimalAttributeMetadata?text=DecimalAttributeMetadata EntityType" /> attributes. To access this property you must cast the attributes collection either as <xref href="Microsoft.Dynamics.CRM.MoneyAttributeMetadata?text=MoneyAttributeMetadata EntityType" /> or <xref href="Microsoft.Dynamics.CRM.DecimalAttributeMetadata?text=DecimalAttributeMetadata EntityType" />. An example showing casting to `MoneyAttributeMetadata` is shown here.
133+
131134
```http
132135
GET [Organization URI]/api/data/v9.0/EntityDefinitions(LogicalName='account')/Attributes/Microsoft.Dynamics.CRM.MoneyAttributeMetadata?$select=LogicalName,Precision
133136
```
@@ -250,7 +253,6 @@ Additional options removed for brevity
250253
"HasChanged": null
251254
}
252255
}
253-
254256
```
255257

256258
If you don’t require any properties of the attribute and only want the values of a collection-valued navigation property such as OptionsSet, you can include that in the URL and limit the properties with a `$select` system query option for a somewhat more efficient query. In the following example only the Options property of the OptionSet are included.
@@ -269,7 +271,7 @@ OData-Version: 4.0
269271
HTTP/1.1 200 OK
270272
Content-Type: application/json; odata.metadata=minimal
271273
OData-Version: 4.0
272-
274+
273275
{
274276
"@odata.context": "[Organization URI]/api/data/v9.0/$metadata#EntityDefinitions('account')/Attributes(5967e7cc-afbb-4c10-bf7e-e7ef430c52be)/Microsoft.Dynamics.CRM.PicklistAttributeMetadata/OptionSet(Options)/$entity",
275277
"Options": [{
@@ -309,15 +311,15 @@ Additional options removed for brevity
309311

310312
## Querying relationship metadata
311313

312-
You can retrieve relationship metadata in the context of a given entity much in the same way that you can query attributes. The ManyToManyRelationships, ManyToOneRelationships, and OneToManyRelationships collection-valued navigation properties can be queried just like the Attributes collection-valued navigation property. More information:[Querying EntityMetadata Attributes](query-metadata-web-api.md#bkmk_queryAttributes)
314+
You can retrieve relationship metadata in the context of a given entity much in the same way that you can query attributes. The `ManyToManyRelationships`, `ManyToOneRelationships`, and `OneToManyRelationships` collection-valued navigation properties can be queried just like the `Attributes` collection-valued navigation property. More information: [Querying EntityMetadata Attributes](query-metadata-web-api.md#bkmk_queryAttributes)
313315

314-
However, entity relationships can also be queried using the RelationshipDefinitions entity set. You can use a query like the following to get the SchemaName property for every relationship.
316+
However, entity relationships can also be queried using the `RelationshipDefinitions` entity set. You can use a query like the following to get the `SchemaName` property for every relationship.
315317

316318
```http
317319
GET [Organization URI]/api/data/v9.0/RelationshipDefinitions?$select=SchemaName
318320
```
319321

320-
The properties available when querying this entity set are limited to those in the <xref href="Microsoft.Dynamics.CRM.RelationshipMetadataBase?text=RelationshipMetadataBase EntityType" />. To access properties from the entity types that inherit from RelationshipMetadataBase you need to include a cast in the query like the following one to return only <xref href="Microsoft.Dynamics.CRM.OneToManyRelationshipMetadata?text=OneToManyRelationshipMetadata EntityType" />.
322+
The properties available when querying this entity set are limited to those in the <xref href="Microsoft.Dynamics.CRM.RelationshipMetadataBase?text=RelationshipMetadataBase EntityType" />. To access properties from the entity types that inherit from `RelationshipMetadataBase` you need to include a cast in the query like the following one to return only <xref href="Microsoft.Dynamics.CRM.OneToManyRelationshipMetadata?text=OneToManyRelationshipMetadata EntityType" />.
321323

322324
```http
323325
GET [Organization URI]/api/data/v9.0/RelationshipDefinitions/Microsoft.Dynamics.CRM.OneToManyRelationshipMetadata?$select=SchemaName
@@ -339,7 +341,7 @@ GET [Organization URI]/api/data/v9.0/EntityDefinitions(LogicalName='account')/On
339341

340342
## Querying Global OptionSets
341343

342-
You can use the `GlobalOptionSetDefinitions` entity set path to retrieve information about global option sets, but this path does not support the use of the `$filter` system query option. So, unless you know the `MetadataId` for a specific global option set, you can only retrieve all of them. You can also access the definition of a global option set from within the `GlobalOptionSet` single-valued navigation property for any attribute that uses it. This is available for all the [EnumAttributeMetadata EntityType Derived Types](/dynamics365/customer-engagement/web-api/enumattributemetadata?view=dynamics-ce-odata-9#Derived_Types). More information:[Retrieving attributes](query-metadata-web-api.md#bkmk_retrieveAttributes)
344+
You can use the `GlobalOptionSetDefinitions` entity set path to retrieve information about global option sets, but this path does not support the use of the `$filter` system query option. So, unless you know the `MetadataId` for a specific global option set, you can only retrieve all of them. You can also access the definition of a global option set from within the `GlobalOptionSet` single-valued navigation property for any attribute that uses it. This is available for all the [EnumAttributeMetadata EntityType Derived Types](/dynamics365/customer-engagement/web-api/enumattributemetadata?view=dynamics-ce-odata-9#Derived_Types). More information: [Retrieving attributes](query-metadata-web-api.md#bkmk_retrieveAttributes)
343345

344346
### See also
345347

powerapps-docs/developer/common-data-service/webapi/use-web-api-metadata.md

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: "Use the Web API with metadata (Common Data Service for Apps) | Microsoft Docs"
33
description: "The section provides guidance about how to use the Web API with the entity types included in Web API Metadata EntityType Reference."
44
ms.custom: ""
5-
ms.date: 10/31/2018
5+
ms.date: 11/04/2018
66
ms.reviewer: ""
77
ms.service: "crm-online"
88
ms.suite: ""
@@ -46,22 +46,22 @@ These entities have some substantial differences from the entities that store bu
4646

4747
## In This Section
4848

49-
[Query Metadata using the Web API](query-metadata-web-api.md)
50-
You can use the Web API to query metadata in a manner similar to what can be done using the <xref:Microsoft.Xrm.Sdk.Messages.RetrieveMetadataChangesRequest> and the objects in the <xref:Microsoft.Xrm.Sdk.Metadata.Query> namespace using the organization service.
51-
52-
[Retrieve metadata by name or MetadataId](retrieve-metadata-name-metadataid.md)
53-
Your applications can adapt to configuration changes by querying the metadata. When you know one of the key properties of a metadata item, you can retrieve metadata definitions using the Web API.
54-
55-
[Create and update model entities using the Web API](create-update-entity-definitions-using-web-api.md)
56-
You can create and update entities and attributes using the Web API to achieve the same results you get with the organization service <xref:Microsoft.Xrm.Sdk.Messages.CreateEntityRequest>, <xref:Microsoft.Xrm.Sdk.Messages.UpdateEntityRequest>, <xref:Microsoft.Xrm.Sdk.Messages.CreateAttributeRequest>, and <xref:Microsoft.Xrm.Sdk.Messages.UpdateAttributeRequest>.
57-
58-
[Create and update entity relationships using the Web API](create-update-entity-relationships-using-web-api.md)
59-
You can check whether entities are eligible to participate in a relationship with other entities and then create or update those relationships using the Web API.
60-
49+
[Query Metadata using the Web API](query-metadata-web-api.md)<br />
50+
You can use the Web API to query metadata using a RESTful query style.
51+
52+
[Retrieve metadata by name or MetadataId](retrieve-metadata-name-metadataid.md)<br />
53+
Your applications can adapt to configuration changes by querying the metadata. When you know one of the key properties of a metadata item, you can retrieve metadata definitions using the Web API.
54+
55+
[Create and update entity definitions using the Web API](create-update-entity-definitions-using-web-api.md)<br />
56+
You can create and update entities and attributes using the Web API to achieve the same results you get with the organization service <xref:Microsoft.Xrm.Sdk.Messages.CreateEntityRequest>, <xref:Microsoft.Xrm.Sdk.Messages.UpdateEntityRequest>, <xref:Microsoft.Xrm.Sdk.Messages.CreateAttributeRequest>, and <xref:Microsoft.Xrm.Sdk.Messages.UpdateAttributeRequest>.
57+
58+
[Create and update entity relationships using the Web API](create-update-entity-relationships-using-web-api.md)<br />
59+
You can check whether entities are eligible to participate in a relationship with other entities and then create or update those relationships using the Web API.
60+
6161
### See also
6262

63-
<!-- TODO:
64-
[Metadata and data models](../metadata-data-models.md)<br />
65-
[Browse the Metadata for Your Organization](../browse-your-metadata.md)<br />
66-
[Use the Organization service with Common Data Service for Apps metadata](../org-service/use-organization-service-metadata.md)<br />
67-
[Use the Common Data Service for Apps Web API](overview.md) -->
63+
64+
<!-- TODO [Metadata and data models](../metadata-data-models.md)<br /> -->
65+
[Browse the metadata for your environment](../browse-your-metadata.md)<br />
66+
<!-- TODO [Use the Organization service with Common Data Service for Apps metadata](../org-service/use-organization-service-metadata.md)<br /> -->
67+
[Use the Common Data Service for Apps Web API](overview.md)

0 commit comments

Comments
 (0)