You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: powerapps-docs/developer/common-data-service/webapi/query-metadata-web-api.md
+18-16Lines changed: 18 additions & 16 deletions
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
title: "Query metadata using the Web API (Common Data Service for Apps) | Microsoft Docs"
3
3
description: "The capability to query system metadata is available using the Web API as well as using the organization service by using RetrieveMetadataChangesRequest"
4
4
ms.custom: ""
5
-
ms.date: 10/31/2018
5
+
ms.date: 11/04/2018
6
6
ms.reviewer: ""
7
7
ms.service: "crm-online"
8
8
ms.suite: ""
@@ -23,8 +23,11 @@ search.app:
23
23
---
24
24
# Query metadata using the Web API
25
25
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 <xrefhref="Microsoft.Dynamics.CRM.EntityQueryExpression?text=EntityQueryExpression ComplexType" /> with the <xrefhref="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
+
28
31
<aname="bkmk_QueryingEntityMetadata"></a>
29
32
30
33
## Querying the EntityMetadata entity type
@@ -85,7 +88,7 @@ There are no limits on the number of metadata entities that will be returned in
85
88
86
89
## Use enum types in $filter operations
87
90
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 <xrefhref="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 <xrefhref="Microsoft.Dynamics.CRM.OwnershipTypes?text=OwnershipTypes EnumType" />, you can use the following `$filter` to return only those entities that are UserOwned.
89
92
90
93
```http
91
94
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
96
99
## Use complex types in $filter operations
97
100
98
101
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 <xrefhref="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
+
100
103
```http
101
104
GET [Organization URI]/api/data/v9.0/EntityDefinitions?$select=LogicalName&$filter=CanCreateAttributes/Value eq true
102
105
```
@@ -107,17 +110,17 @@ This pattern works with <xref href="Microsoft.Dynamics.CRM.BooleanManagedPropert
107
110
108
111
## Querying EntityMetadata attributes
109
112
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 <xrefhref="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 <xrefhref="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 <xrefhref="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 <xrefhref="Microsoft.Dynamics.CRM.AttributeTypeCode?text=AttributeTypeCode EnumType" /> value of `Picklist`.
111
114
112
115
<aname="bkmk_queryAttributesexample"></a>
113
116
114
117
```http
115
118
GET [Organization URI]/api/data/v9.0/EntityDefinitions(LogicalName='account')?$select=LogicalName&$expand=Attributes($select=LogicalName;$filter=AttributeType eq Microsoft.Dynamics.CRM.AttributeTypeCode'Picklist')
116
119
```
117
120
118
-
But you can’t include the OptionSet or GlobalOptionSet collection-valued navigation properties that <xrefhref="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 <xrefhref="Microsoft.Dynamics.CRM.PicklistAttributeMetadata?text=PicklistAttributeMetadata EntityType" /> attributes have within the `$select` filter of this query.
119
122
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 PicklistAttributeMetadataattributes 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 <xrefhref="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
121
124
122
125
```http
123
126
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
126
129
> [!NOTE]
127
130
> Despite the fact that the `OptionSet` and `GlobalOptionSet` collection-valued navigation properties are defined within <xrefhref="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.
128
131
129
-
Another example of this is accessing the Precision property available in <xrefhref="Microsoft.Dynamics.CRM.MoneyAttributeMetadata?text=MoneyAttributeMetadata EntityType" /> and <xrefhref="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 <xrefhref="Microsoft.Dynamics.CRM.MoneyAttributeMetadata?text=MoneyAttributeMetadata EntityType" /> and <xrefhref="Microsoft.Dynamics.CRM.DecimalAttributeMetadata?text=DecimalAttributeMetadata EntityType" /> attributes. To access this property you must cast the attributes collection either as <xrefhref="Microsoft.Dynamics.CRM.MoneyAttributeMetadata?text=MoneyAttributeMetadata EntityType" /> or <xrefhref="Microsoft.Dynamics.CRM.DecimalAttributeMetadata?text=DecimalAttributeMetadata EntityType" />. An example showing casting to `MoneyAttributeMetadata` is shown here.
133
+
131
134
```http
132
135
GET [Organization URI]/api/data/v9.0/EntityDefinitions(LogicalName='account')/Attributes/Microsoft.Dynamics.CRM.MoneyAttributeMetadata?$select=LogicalName,Precision
133
136
```
@@ -250,7 +253,6 @@ Additional options removed for brevity
250
253
"HasChanged": null
251
254
}
252
255
}
253
-
254
256
```
255
257
256
258
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.
@@ -309,15 +311,15 @@ Additional options removed for brevity
309
311
310
312
## Querying relationship metadata
311
313
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)
313
315
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.
315
317
316
318
```http
317
319
GET [Organization URI]/api/data/v9.0/RelationshipDefinitions?$select=SchemaName
318
320
```
319
321
320
-
The properties available when querying this entity set are limited to those in the <xrefhref="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 <xrefhref="Microsoft.Dynamics.CRM.OneToManyRelationshipMetadata?text=OneToManyRelationshipMetadata EntityType" />.
322
+
The properties available when querying this entity set are limited to those in the <xrefhref="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 <xrefhref="Microsoft.Dynamics.CRM.OneToManyRelationshipMetadata?text=OneToManyRelationshipMetadata EntityType" />.
321
323
322
324
```http
323
325
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
339
341
340
342
## Querying Global OptionSets
341
343
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)
Copy file name to clipboardExpand all lines: powerapps-docs/developer/common-data-service/webapi/use-web-api-metadata.md
+18-18Lines changed: 18 additions & 18 deletions
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
title: "Use the Web API with metadata (Common Data Service for Apps) | Microsoft Docs"
3
3
description: "The section provides guidance about how to use the Web API with the entity types included in Web API Metadata EntityType Reference."
4
4
ms.custom: ""
5
-
ms.date: 10/31/2018
5
+
ms.date: 11/04/2018
6
6
ms.reviewer: ""
7
7
ms.service: "crm-online"
8
8
ms.suite: ""
@@ -46,22 +46,22 @@ These entities have some substantial differences from the entities that store bu
46
46
47
47
## In This Section
48
48
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
+
61
61
### See also
62
62
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