Remarque
L’accès à cette page nécessite une autorisation. Vous pouvez essayer de vous connecter ou de modifier des répertoires.
L’accès à cette page nécessite une autorisation. Vous pouvez essayer de modifier des répertoires.
Vos applications peuvent s’adapter aux modifications de configuration en interrogeant les définitions de table et de colonne (métadonnées). Lorsque vous connaissez l’une des propriétés clés d’un élément de définition, vous pouvez récupérer des définitions à l’aide de l’API Web.
Note
Cette rubrique décrit la récupération des définitions de table et d’autres entités de schéma par nom. Toutefois, vous pouvez également utiliser les noms lors de l’exécution d’autres opérations pour créer, mettre à jour et supprimer des entités de schéma.
Récupérer les éléments de définition par nom
Tous les éléments de définition récupérables ont une MetadataId clé primaire qui peut être utilisée pour récupérer des éléments individuels. Pour les définitions qui ont une autre clé, vous pouvez les récupérer par nom.
La récupération d’éléments de définition par nom est plus facile, car vous disposez probablement déjà d’une référence au nom de l’élément dans votre code. Le tableau suivant répertorie les autres propriétés de clé pour récupérer ces éléments par nom.
| Élément de définition | Autre clé | Example |
|---|---|---|
| Entité | LogicalName | GET /api/data/v9.2/EntityDefinitions(LogicalName='account') |
| Caractéristique | LogicalName | GET /api/data/v9.2/EntityDefinitions(LogicalName='account')/Attributes(LogicalName='emailaddress1') |
| Relation | SchemaName | GET /api/data/v9.2/RelationshipDefinitions(SchemaName='Account_Tasks') |
| Ensemble d’options globales | Nom | GET /api/data/v9.2/GlobalOptionSetDefinitions(Name='metric_goaltype') |
Exemple : Récupérer des éléments de définition par nom
Un élément de définition courant que les utilisateurs souhaitent récupérer sont les options configurées pour un attribut particulier. L’exemple suivant montre comment récupérer les propriétés OptionSet et GlobalOptionSet d’un PicklistAttributeMetadata EntityType.
Note
Le développement des OptionSetGlobalOptionSet propriétés de navigation à valeur unique de PicklistAttributeMetadata EntityType vous permet d’obtenir la définition d’option si l’attribut est configuré pour utiliser des ensembles d’options globaux ou l’option « local » définie dans l’entité. S’il s’agit d’un jeu d’options « local », la GlobalOptionSet propriété est null, comme indiqué ci-dessous.
Si l’attribut a utilisé un ensemble d’options globales, la GlobalOptionSet propriété contient les options définies et la OptionSet propriété est null.
Requête :
GET [Organization URI]/api/data/v9.2/EntityDefinitions(LogicalName='account')/Attributes(LogicalName='accountcategorycode')/Microsoft.Dynamics.CRM.PicklistAttributeMetadata?$select=LogicalName&$expand=OptionSet($select=Options),GlobalOptionSet($select=Options) HTTP/1.1
OData-MaxVersion: 4.0
OData-Version: 4.0
Accept: application/json
Content-Type: application/json; charset=utf-8
Réponse:
HTTP/1.1 200 OK
Content-Type: application/json; odata.metadata=minimal
OData-Version: 4.0
{
"@odata.context": "[Organization URI]/api/data/v9.2/$metadata#EntityDefinitions('account')/Attributes/Microsoft.Dynamics.CRM.PicklistAttributeMetadata(LogicalName,OptionSet,GlobalOptionSet,OptionSet(Options),GlobalOptionSet(Options))/$entity",
"LogicalName": "accountcategorycode",
"MetadataId": "118771ca-6fb9-4f60-8fd4-99b6124b63ad",
"OptionSet@odata.context": "[Organization URI]/api/data/v9.2/$metadata#EntityDefinitions('account')/Attributes(118771ca-6fb9-4f60-8fd4-99b6124b63ad)/Microsoft.Dynamics.CRM.PicklistAttributeMetadata/OptionSet(Options)/$entity",
"OptionSet": {
"Options": [{
"Value": 1,
"Label": {
"LocalizedLabels": [{
"Label": "Preferred Customer",
"LanguageCode": 1033,
"IsManaged": true,
"MetadataId": "0bd8a218-2341-db11-898a-0007e9e17ebd",
"HasChanged": null
}],
"UserLocalizedLabel": {
"Label": "Preferred Customer",
"LanguageCode": 1033,
"IsManaged": true,
"MetadataId": "0bd8a218-2341-db11-898a-0007e9e17ebd",
"HasChanged": null
}
},
"Description": {
"LocalizedLabels": [
],
"UserLocalizedLabel": null
},
"Color": null,
"IsManaged": true,
"MetadataId": null,
"HasChanged": null
}, {
"Value": 2,
"Label": {
"LocalizedLabels": [{
"Label": "Standard",
"LanguageCode": 1033,
"IsManaged": true,
"MetadataId": "0dd8a218-2341-db11-898a-0007e9e17ebd",
"HasChanged": null
}],
"UserLocalizedLabel": {
"Label": "Standard",
"LanguageCode": 1033,
"IsManaged": true,
"MetadataId": "0dd8a218-2341-db11-898a-0007e9e17ebd",
"HasChanged": null
}
},
"Description": {
"LocalizedLabels": [
],
"UserLocalizedLabel": null
},
"Color": null,
"IsManaged": true,
"MetadataId": null,
"HasChanged": null
}],
"MetadataId": "b994cdd8-5ce9-4ab9-bdd3-8888ebdb0407"
},
"GlobalOptionSet": null
}
Récupérer des éléments de définition par MetadataId
Comme il MetadataId s’agit de la clé primaire des éléments de définition, la récupération d’éléments individuels suit le même modèle que celui utilisé pour récupérer des tables de données métiers.
| Élément de définition | Example |
|---|---|
| Entité | GET /api/data/v9.2/EntityDefinitions(<Entity MetadataId>) |
| Caractéristique | GET /api/data/v9.2/EntityDefinitions(<Entity MetadataId>)/Attributes(<Attribute MetadataId>) |
| Relation | GET /api/data/v9.2/RelationshipDefinitions(<Relationship MetadataId>) |
| Ensemble d’options globales | GET /api/data/v9.2/GlobalOptionSetDefinitions(<OptionSet MetadataId>) |
Exemple : Récupérer des éléments de définition par MetadataId
Pour obtenir le même résultat que celui indiqué dans l’exemple : récupérer les éléments de définition par nom, vous devez effectuer une série d’opérations de requête pour obtenir le MetadataId filtrage par l’entité LogicalName , puis par l’attribut LogicalName.
Requête :
GET [Organization URI]/api/data/v9.2/EntityDefinitions?$filter=LogicalName%20eq%20'account'&$select=MetadataId HTTP/1.1
OData-MaxVersion: 4.0
OData-Version: 4.0
Accept: application/json
Content-Type: application/json; charset=utf-8
Réponse:
HTTP/1.1 200 OK
Content-Type: application/json; odata.metadata=minimal
OData-Version: 4.0
{
"@odata.context":"[Organization URI]/api/data/v9.2/$metadata#EntityDefinitions(MetadataId)","value":[
{
"MetadataId":"70816501-edb9-4740-a16c-6a5efbc05d84"
}
]
}
Requête :
GET [Organization URI]/api/data/v9.2/EntityDefinitions(70816501-edb9-4740-a16c-6a5efbc05d84)/Attributes?$filter=LogicalName%20eq%20'accountcategorycode'&$select=MetadataId HTTP/1.1
OData-MaxVersion: 4.0
OData-Version: 4.0
Accept: application/json
Content-Type: application/json; charset=utf-8
Réponse:
HTTP/1.1 200 OK
Content-Type: application/json; odata.metadata=minimal
OData-Version: 4.0
{
"@odata.context": "[Organization URI]/api/data/v9.2/$metadata#EntityDefinitions(70816501-edb9-4740-a16c-6a5efbc05d84)/Attributes(MetadataId)","value":[
{
"@odata.type": "#Microsoft.Dynamics.CRM.PicklistAttributeMetadata",
"MetadataId": "118771ca-6fb9-4f60-8fd4-99b6124b63ad"
}
]
}
Requête :
GET [Organization URI]/api/data/v9.2/EntityDefinitions(70816501-edb9-4740-a16c-6a5efbc05d84)/Attributes(118771ca-6fb9-4f60-8fd4-99b6124b63ad)/Microsoft.Dynamics.CRM.PicklistAttributeMetadata?$select=LogicalName&$expand=OptionSet($select=Options),GlobalOptionSet($select=Options) HTTP/1.1
OData-MaxVersion: 4.0
OData-Version: 4.0
Accept: application/json
Content-Type: application/json; charset=utf-8
Réponse:
HTTP/1.1 200 OK
Content-Type: application/json; odata.metadata=minimal
OData-Version: 4.0
{
"@odata.context": "[Organization URI]/api/data/v9.2/$metadata#EntityDefinitions(70816501-edb9-4740-a16c-6a5efbc05d84)/Attributes/Microsoft.Dynamics.CRM.PicklistAttributeMetadata(LogicalName,OptionSet,GlobalOptionSet,OptionSet(Options),GlobalOptionSet(Options))/$entity",
"LogicalName": "accountcategorycode",
"MetadataId": "118771ca-6fb9-4f60-8fd4-99b6124b63ad",
"OptionSet@odata.context": "[Organization URI]/api/data/v9.2/$metadata#EntityDefinitions(70816501-edb9-4740-a16c-6a5efbc05d84)/Attributes(118771ca-6fb9-4f60-8fd4-99b6124b63ad)/Microsoft.Dynamics.CRM.PicklistAttributeMetadata/OptionSet(Options)/$entity",
"OptionSet": {
"Options": [{
"Value": 1,
"Label": {
"LocalizedLabels": [{
"Label": "Preferred Customer",
"LanguageCode": 1033,
"IsManaged": true,
"MetadataId": "0bd8a218-2341-db11-898a-0007e9e17ebd",
"HasChanged": null
}],
"UserLocalizedLabel": {
"Label": "Preferred Customer",
"LanguageCode": 1033,
"IsManaged": true,
"MetadataId": "0bd8a218-2341-db11-898a-0007e9e17ebd",
"HasChanged": null
}
},
"Description": {
"LocalizedLabels": [
],
"UserLocalizedLabel": null
},
"Color": null,
"IsManaged": true,
"MetadataId": null,
"HasChanged": null
}, {
"Value": 2,
"Label": {
"LocalizedLabels": [{
"Label": "Standard",
"LanguageCode": 1033,
"IsManaged": true,
"MetadataId": "0dd8a218-2341-db11-898a-0007e9e17ebd",
"HasChanged": null
}],
"UserLocalizedLabel": {
"Label": "Standard",
"LanguageCode": 1033,
"IsManaged": true,
"MetadataId": "0dd8a218-2341-db11-898a-0007e9e17ebd",
"HasChanged": null
}
},
"Description": {
"LocalizedLabels": [
],
"UserLocalizedLabel": null
},
"Color": null,
"IsManaged": true,
"MetadataId": null,
"HasChanged": null
}],
"MetadataId": "b994cdd8-5ce9-4ab9-bdd3-8888ebdb0407"
},
"GlobalOptionSet": null
}
Voir aussi
Utiliser l’API Web avec les définitions de table
Requête des définitions de table à l’aide de l’API web
Créer et mettre à jour les définitions de table à l’aide de l’API Web
Créer et mettre à jour des relations de table à l’aide de l’API web
Exemple d’opérations de schéma de table de l’API Web
Exemple d’opérations de schéma de table de l’API Web (C#)