Nota
O acceso a esta páxina require autorización. Pode tentar iniciar sesión ou modificar os directorios.
O acceso a esta páxina require autorización. Pode tentar modificar os directorios.
Puede realizar las mismas operaciones en las definiciones de columna mediante la API web como con el SDK para .NET. Este artículo se centra en trabajar con definiciones de columna (metadatos) mediante la API web.
Crear columnas
Puede crear columnas de tabla (atributos de entidad) al mismo tiempo que cree la definición de tabla mediante la inclusión de la definición JSON de los atributos de la Attributes matriz para la entidad que publique además del atributo de cadena que actúa como atributo de nombre principal. Si desea agregar atributos a una entidad que ya se ha creado, puede enviar una POST solicitud que incluya la definición JSON de dichos atributos a la propiedad de navegación de colección de la entidad Attributes.
En los ejemplos siguientes se muestra cómo crear diferentes tipos de columnas.
- Creación de una columna de cadena
- Crear una columna de dinero
- Creación de una columna datetime
- Creación de una columna booleana
- Creación de una columna de búsqueda de clientes
- Creación de una columna decimal
- Creación de una columna de enteros
- Crear una columna de tipo memo
- Creación de una columna de elección
- Crear una columna de selección múltiple
- Creación de una columna de entero grande
Creación de una columna de cadena
En el ejemplo siguiente se usan estas propiedades para crear una columna de cadena.
| Propiedades de StringAttributeMetadata | Valores |
|---|---|
SchemaName |
new_BankName |
DisplayName |
Nombre del banco |
Description |
Escriba el nombre del banco. |
RequiredLevel |
None |
MaxLength |
100 |
FormatName |
Text |
En el ejemplo siguiente se crea una columna de cadena mediante las propiedades y se agrega a la sample_bankaccount tabla.
El URI del atributo se devuelve en la respuesta.
Solicitud:
POST [Organization URI]/api/data/v9.2/EntityDefinitions(LogicalName='sample_bankaccount')/Attributes HTTP/1.1
MSCRM.SolutionUniqueName: examplesolution
Accept: application/json
Content-Type: application/json; charset=utf-8
OData-MaxVersion: 4.0
OData-Version: 4.0
{
"AttributeType": "String",
"AttributeTypeName": {
"Value": "StringType"
},
"Description": {
"@odata.type": "Microsoft.Dynamics.CRM.Label",
"LocalizedLabels": [
{
"@odata.type": "Microsoft.Dynamics.CRM.LocalizedLabel",
"Label": "Type the name of the bank",
"LanguageCode": 1033
}
]
},
"DisplayName": {
"@odata.type": "Microsoft.Dynamics.CRM.Label",
"LocalizedLabels": [
{
"@odata.type": "Microsoft.Dynamics.CRM.LocalizedLabel",
"Label": "Bank Name",
"LanguageCode": 1033
}
]
},
"RequiredLevel": {
"Value": "None",
"CanBeChanged": true,
"ManagedPropertyLogicalName": "canmodifyrequirementlevelsettings"
},
"SchemaName": "new_BankName",
"@odata.type": "Microsoft.Dynamics.CRM.StringAttributeMetadata",
"FormatName": {
"Value": "Text"
},
"MaxLength": 100
}
Respuesta:
HTTP/1.1 204 No Content
OData-Version: 4.0
OData-EntityId: [Organization URI]/api/data/v9.2/EntityDefinitions(LogicalName='sample_bankaccount')/Attributes(00aa00aa-bb11-cc22-dd33-44ee44ee44ee)
Crear una columna "money"
En el ejemplo siguiente se usan estas propiedades para crear un atributo money.
| Propiedades de MoneyAttributeMetadata | Valores |
|---|---|
SchemaName |
new_Balance |
DisplayName |
Saldo |
Description |
Escriba el importe del saldo. |
RequiredLevel |
Ninguno |
PrecisionSource |
2 Nota: Para obtener información sobre los valores válidos para PrecisionSource, vea MoneyType. El valor 2 significa que el nivel de precisión decimal coincide con TransactionCurrency.CurrencyPrecision que está asociado al registro actual. |
En el ejemplo siguiente se crea un atributo money mediante las propiedades y se agrega a la sample_bankaccount tabla. El URI del atributo se devuelve en la respuesta.
Solicitud:
POST [Organization URI]/api/data/v9.2/EntityDefinitions(LogicalName='sample_bankaccount')/Attributes HTTP/1.1
MSCRM.SolutionUniqueName: examplesolution
Accept: application/json
Content-Type: application/json; charset=utf-8
OData-MaxVersion: 4.0
OData-Version: 4.0
{
"AttributeType": "Money",
"AttributeTypeName": {
"Value": "MoneyType"
},
"Description": {
"@odata.type": "Microsoft.Dynamics.CRM.Label",
"LocalizedLabels": [
{
"@odata.type": "Microsoft.Dynamics.CRM.LocalizedLabel",
"Label": "Enter the balance amount",
"LanguageCode": 1033
}
]
},
"DisplayName": {
"@odata.type": "Microsoft.Dynamics.CRM.Label",
"LocalizedLabels": [
{
"@odata.type": "Microsoft.Dynamics.CRM.LocalizedLabel",
"Label": "Balance",
"LanguageCode": 1033
}
]
},
"RequiredLevel": {
"Value": "None",
"CanBeChanged": true,
"ManagedPropertyLogicalName": "canmodifyrequirementlevelsettings"
},
"SchemaName": "new_Balance",
"@odata.type": "Microsoft.Dynamics.CRM.MoneyAttributeMetadata",
"PrecisionSource": 2
}
Respuesta:
HTTP/1.1 204 No Content
OData-Version: 4.0
OData-EntityId: [Organization URI]/api/data/v9.2/EntityDefinitions(LogicalName='sample_bankaccount')/Attributes(11bb11bb-cc22-dd33-ee44-55ff55ff55ff)
Creación de una columna datetime
En el ejemplo siguiente se usan estas propiedades para crear un atributo datetime.
| Propiedades DateTimeAttributeMetadata | Valores |
|---|---|
SchemaName |
new_Checkeddate |
DisplayName |
Date |
Description |
Fecha en la que se confirmó por última vez el saldo de la cuenta. |
RequiredLevel |
None |
Format |
DateOnly
Nota: Para ver las opciones válidas de esta propiedad, vea DateTimeFormat EnumType. |
En el ejemplo siguiente se crea un atributo datetime mediante las propiedades y se agrega a la sample_bankaccount tabla.
El URI del atributo se devuelve en la respuesta.
Solicitud:
POST [Organization URI]/api/data/v9.2/EntityDefinitions(LogicalName='sample_bankaccount')/Attributes HTTP/1.1
MSCRM.SolutionUniqueName: examplesolution
Accept: application/json
Content-Type: application/json; charset=utf-8
OData-MaxVersion: 4.0
OData-Version: 4.0
{
"AttributeType": "DateTime",
"AttributeTypeName": {
"Value": "DateTimeType"
},
"Description": {
"@odata.type": "Microsoft.Dynamics.CRM.Label",
"LocalizedLabels": [
{
"@odata.type": "Microsoft.Dynamics.CRM.LocalizedLabel",
"Label": "The date the account balance was last confirmed",
"LanguageCode": 1033
}
]
},
"DisplayName": {
"@odata.type": "Microsoft.Dynamics.CRM.Label",
"LocalizedLabels": [
{
"@odata.type": "Microsoft.Dynamics.CRM.LocalizedLabel",
"Label": "Date",
"LanguageCode": 1033
}
]
},
"RequiredLevel": {
"Value": "None",
"CanBeChanged": true,
"ManagedPropertyLogicalName": "canmodifyrequirementlevelsettings"
},
"SchemaName": "new_Checkeddate",
"@odata.type": "Microsoft.Dynamics.CRM.DateTimeAttributeMetadata",
"Format": "DateOnly"
}
Respuesta:
HTTP/1.1 204 No Content
OData-Version: 4.0
OData-EntityId: [Organization URI]/api/data/v9.2/EntityDefinitions(LogicalName='sample_bankaccount')/Attributes(22cc22cc-dd33-ee44-ff55-66aa66aa66aa)
Creación de una columna booleana
En el ejemplo siguiente se usan estas propiedades para crear una columna booleana.
| Propiedades de BooleanAttributeMetadata | Valores |
|---|---|
SchemaName |
new_Boolean |
DisplayName |
Boolean de ejemplo |
Description |
Atributo booleano |
RequiredLevel |
None |
OptionSet.TrueOption |
Cierto |
OptionSet.FalseOption |
Falso |
El siguiente ejemplo crea un atributo booleano mediante las propiedades y lo agrega a la entidad con el valor LogicalName de new_bankaccount. El URI del atributo se devuelve en la respuesta.
Solicitud:
POST [Organization Uri]/api/data/v9.2/EntityDefinitions(LogicalName='new_bankaccount')/Attributes HTTP/1.1
MSCRM.SolutionUniqueName: examplesolution
OData-MaxVersion: 4.0
OData-Version: 4.0
If-None-Match: null
Accept: application/json
{
"@odata.type": "Microsoft.Dynamics.CRM.BooleanAttributeMetadata",
"AttributeType": "Boolean",
"AttributeTypeName": {
"Value": "BooleanType"
},
"DefaultValue": false,
"OptionSet": {
"TrueOption": {
"Value": 1,
"Label": {
"@odata.type": "Microsoft.Dynamics.CRM.Label",
"LocalizedLabels": [
{
"@odata.type": "Microsoft.Dynamics.CRM.LocalizedLabel",
"Label": "True",
"LanguageCode": 1033,
"IsManaged": false
}
]
}
},
"FalseOption": {
"Value": 0,
"Label": {
"@odata.type": "Microsoft.Dynamics.CRM.Label",
"LocalizedLabels": [
{
"@odata.type": "Microsoft.Dynamics.CRM.LocalizedLabel",
"Label": "False",
"LanguageCode": 1033,
"IsManaged": false
}
]
}
},
"OptionSetType": "Boolean"
},
"Description": {
"@odata.type": "Microsoft.Dynamics.CRM.Label",
"LocalizedLabels": [
{
"@odata.type": "Microsoft.Dynamics.CRM.LocalizedLabel",
"Label": "Boolean Attribute",
"LanguageCode": 1033,
"IsManaged": false
}
]
},
"DisplayName": {
"@odata.type": "Microsoft.Dynamics.CRM.Label",
"LocalizedLabels": [
{
"@odata.type": "Microsoft.Dynamics.CRM.LocalizedLabel",
"Label": "Sample Boolean",
"LanguageCode": 1033,
"IsManaged": false
}
]
},
"RequiredLevel": {
"Value": "None",
"CanBeChanged": false,
"ManagedPropertyLogicalName": "canmodifyrequirementlevelsettings"
},
"SchemaName": "new_Boolean"
}
Respuesta:
HTTP/1.1 NoContent
OData-Version: 4.0
OData-EntityId: [Organization Uri]/api/data/v9.2/EntityDefinitions(LogicalName='new_bankaccount')/Attributes(33dd33dd-ee44-ff55-aa66-77bb77bb77bb)
Creación de una columna de búsqueda de clientes
A diferencia de otros atributos, se crea un atributo de búsqueda de clientes mediante la acción CreateCustomerRelationships.
Los parámetros de esta acción requieren la definición del atributo de búsqueda y un par de relaciones de uno a varios. Un atributo de búsqueda de cliente tiene dos relaciones de uno a varios: una para la entidad de cuenta y la otra para la entidad de contacto.
En el ejemplo siguiente se usan estas propiedades para crear un atributo de búsqueda de clientes.
| Propiedades del atributo de búsqueda de clientes | Valores |
|---|---|
SchemaName |
new_CustomerId |
DisplayName |
Cliente |
Description |
Atributo de búsqueda de clientes de ejemplo |
En el ejemplo se crea un atributo de búsqueda de cliente, new_CustomerIdy se agrega a la entidad personalizada: new_bankaccount. La respuesta es createCustomerRelationshipsResponse ComplexType".
Solicitud:
POST [Organization URI]/api/data/v9.2/CreateCustomerRelationships HTTP/1.1
MSCRM.SolutionUniqueName: examplesolution
OData-MaxVersion: 4.0
OData-Version: 4.0
Accept: application/json
Content-Type: application/json; charset=utf-8
{
"OneToManyRelationships": [{
"SchemaName": "new_bankaccount_customer_account",
"ReferencedEntity": "account",
"ReferencingEntity": "new_bankaccount"
}, {
"SchemaName": "new_bankaccount_customer_contact",
"ReferencedEntity": "contact",
"ReferencingEntity": "new_bankaccount"
}],
"Lookup": {
"AttributeType": "Lookup",
"AttributeTypeName": {
"Value": "LookupType"
},
"Description": {
"@odata.type": "Microsoft.Dynamics.CRM.Label",
"LocalizedLabels": [{
"@odata.type": "Microsoft.Dynamics.CRM.LocalizedLabel",
"Label": "Sample Customer Lookup Attribute",
"LanguageCode": 1033
}],
"UserLocalizedLabel": {
"@odata.type": "Microsoft.Dynamics.CRM.LocalizedLabel",
"Label": "Sample Customer Lookup Attribute",
"LanguageCode": 1033
}
},
"DisplayName": {
"@odata.type": "Microsoft.Dynamics.CRM.Label",
"LocalizedLabels": [{
"@odata.type": "Microsoft.Dynamics.CRM.LocalizedLabel",
"Label": "Customer",
"LanguageCode": 1033
}],
"UserLocalizedLabel": {
"@odata.type": "Microsoft.Dynamics.CRM.LocalizedLabel",
"Label": "Customer",
"LanguageCode": 1033
}
},
"SchemaName": "new_CustomerId",
"@odata.type": "Microsoft.Dynamics.CRM.ComplexLookupAttributeMetadata"
}
}
Respuesta:
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#Microsoft.Dynamics.CRM.CreateCustomerRelationshipsResponse",
"RelationshipIds": [
"a7d261bc-3580-e611-80d7-00155d2a68de", "aed261bc-3580-e611-80d7-00155d2a68de"
],
"AttributeId": "39a5d94c-e8a2-4a41-acc0-8487242d455e"
}
Creación de una columna decimal
En el ejemplo siguiente se usan estas propiedades para crear una columna decimal.
| Propiedades de DecimalAttributeMetadata | Valores |
|---|---|
SchemaName |
sample_Decimal |
DisplayName |
Decimal de ejemplo |
Description |
Atributo decimal |
RequiredLevel |
None |
MaxValue |
100.0 |
MinValue |
0.0 |
Precision |
1 |
En el ejemplo siguiente se crea un atributo decimal con las propiedades y se agrega a la sample_bankaccount tabla.
El URI del atributo se devuelve en la respuesta.
Solicitud:
POST [Organization Uri]/api/data/v9.2/EntityDefinitions(LogicalName='sample_bankaccount')/Attributes
MSCRM.SolutionUniqueName: examplesolution
OData-MaxVersion: 4.0
OData-Version: 4.0
If-None-Match: null
Accept: application/json
Content-Type: application/json; charset=utf-8
Content-Length: 1370
{
"@odata.type": "Microsoft.Dynamics.CRM.DecimalAttributeMetadata",
"AttributeType": "Decimal",
"AttributeTypeName": {
"Value": "DecimalType"
},
"MaxValue": 100.0,
"MinValue": 0.0,
"Precision": 1,
"Description": {
"@odata.type": "Microsoft.Dynamics.CRM.Label",
"LocalizedLabels": [
{
"@odata.type": "Microsoft.Dynamics.CRM.LocalizedLabel",
"Label": "Decimal Attribute",
"LanguageCode": 1033,
"IsManaged": false
}
],
"UserLocalizedLabel": {
"@odata.type": "Microsoft.Dynamics.CRM.LocalizedLabel",
"Label": "Decimal Attribute",
"LanguageCode": 1033,
"IsManaged": false
}
},
"DisplayName": {
"@odata.type": "Microsoft.Dynamics.CRM.Label",
"LocalizedLabels": [
{
"@odata.type": "Microsoft.Dynamics.CRM.LocalizedLabel",
"Label": "Sample Decimal",
"LanguageCode": 1033,
"IsManaged": false
}
],
"UserLocalizedLabel": {
"@odata.type": "Microsoft.Dynamics.CRM.LocalizedLabel",
"Label": "Sample Decimal",
"LanguageCode": 1033,
"IsManaged": false
}
},
"RequiredLevel": {
"Value": "None",
"CanBeChanged": false,
"ManagedPropertyLogicalName": "canmodifyrequirementlevelsettings"
},
"SchemaName": "sample_Decimal"
}
Respuesta:
HTTP/1.1 204 NoContent
OData-Version: 4.0
OData-EntityId: [Organization Uri]/api/data/v9.2/EntityDefinitions(LogicalName='sample_bankaccount')/Attributes(44ee44ee-ff55-aa66-bb77-88cc88cc88cc)
Creación de una columna de enteros
En el ejemplo siguiente se usan estas propiedades para crear una columna entera.
| Propiedades IntegerAttributeMetadata | Valores |
|---|---|
SchemaName |
sample_Integer |
DisplayName |
Ejemplo de Entero |
Description |
Atributo entero |
RequiredLevel |
None |
MaxValue |
100 |
MinValue |
0 |
Format |
Ninguno |
En el ejemplo siguiente se crea una columna entera con las propiedades y se agrega a la sample_bankaccount tabla.
El URI de la columna se devuelve en la respuesta.
Solicitud:
POST [Organization Uri]/api/data/v9.2/EntityDefinitions(LogicalName='sample_bankaccount')/Attributes
MSCRM.SolutionUniqueName: examplesolution
OData-MaxVersion: 4.0
OData-Version: 4.0
If-None-Match: null
Accept: application/json
Content-Type: application/json; charset=utf-8
Content-Length: 1392
{
"@odata.type": "Microsoft.Dynamics.CRM.IntegerAttributeMetadata",
"AttributeType": "Integer",
"AttributeTypeName": {
"Value": "IntegerType"
},
"MaxValue": 100,
"MinValue": 0,
"Format": "None",
"SourceTypeMask": 0,
"Description": {
"@odata.type": "Microsoft.Dynamics.CRM.Label",
"LocalizedLabels": [
{
"@odata.type": "Microsoft.Dynamics.CRM.LocalizedLabel",
"Label": "Integer Attribute",
"LanguageCode": 1033,
"IsManaged": false
}
],
"UserLocalizedLabel": {
"@odata.type": "Microsoft.Dynamics.CRM.LocalizedLabel",
"Label": "Integer Attribute",
"LanguageCode": 1033,
"IsManaged": false
}
},
"DisplayName": {
"@odata.type": "Microsoft.Dynamics.CRM.Label",
"LocalizedLabels": [
{
"@odata.type": "Microsoft.Dynamics.CRM.LocalizedLabel",
"Label": "Sample Integer",
"LanguageCode": 1033,
"IsManaged": false
}
],
"UserLocalizedLabel": {
"@odata.type": "Microsoft.Dynamics.CRM.LocalizedLabel",
"Label": "Sample Integer",
"LanguageCode": 1033,
"IsManaged": false
}
},
"RequiredLevel": {
"Value": "None",
"CanBeChanged": false,
"ManagedPropertyLogicalName": "canmodifyrequirementlevelsettings"
},
"SchemaName": "sample_Integer"
}
Respuesta:
HTTP/1.1 204 NoContent
OData-Version: 4.0
OData-EntityId: [Organization Uri]/api/data/v9.2/EntityDefinitions(LogicalName='sample_bankaccount')/Attributes(55ff55ff-aa66-bb77-cc88-99dd99dd99dd)
Creación de una columna memo
En el ejemplo siguiente se usan estas propiedades para crear una columna memo.
| Propiedades MemoAttributeMetadata | Valores |
|---|---|
SchemaName |
sample_Memo |
DisplayName |
Memo de ejemplo |
Description |
Atributo Memo |
RequiredLevel |
None |
MaxLength |
500 |
Format |
TextArea |
En el ejemplo siguiente se crea una columna memo con las propiedades y se agrega a la sample_bankaccount tabla.
El URI del atributo se devuelve en la respuesta.
Solicitud:
POST [Organization Uri]/api/data/v9.2/EntityDefinitions(LogicalName='sample_bankaccount')/Attributes
MSCRM.SolutionUniqueName: examplesolution
OData-MaxVersion: 4.0
OData-Version: 4.0
If-None-Match: null
Accept: application/json
Content-Type: application/json; charset=utf-8
Content-Length: 1384
{
"@odata.type": "Microsoft.Dynamics.CRM.MemoAttributeMetadata",
"AttributeType": "Memo",
"AttributeTypeName": {
"Value": "MemoType"
},
"Format": "TextArea",
"ImeMode": "Disabled",
"MaxLength": 500,
"IsLocalizable": false,
"Description": {
"@odata.type": "Microsoft.Dynamics.CRM.Label",
"LocalizedLabels": [
{
"@odata.type": "Microsoft.Dynamics.CRM.LocalizedLabel",
"Label": "Memo Attribute",
"LanguageCode": 1033,
"IsManaged": false
}
],
"UserLocalizedLabel": {
"@odata.type": "Microsoft.Dynamics.CRM.LocalizedLabel",
"Label": "Memo Attribute",
"LanguageCode": 1033,
"IsManaged": false
}
},
"DisplayName": {
"@odata.type": "Microsoft.Dynamics.CRM.Label",
"LocalizedLabels": [
{
"@odata.type": "Microsoft.Dynamics.CRM.LocalizedLabel",
"Label": "Sample Memo",
"LanguageCode": 1033,
"IsManaged": false
}
],
"UserLocalizedLabel": {
"@odata.type": "Microsoft.Dynamics.CRM.LocalizedLabel",
"Label": "Sample Memo",
"LanguageCode": 1033,
"IsManaged": false
}
},
"RequiredLevel": {
"Value": "None",
"CanBeChanged": false,
"ManagedPropertyLogicalName": "canmodifyrequirementlevelsettings"
},
"SchemaName": "sample_Memo"
}
Respuesta:
HTTP/1.1 204 NoContent
OData-Version: 4.0
OData-EntityId: [Organization Uri]/api/data/v9.2/EntityDefinitions(LogicalName='sample_bankaccount')/Attributes(66aa66aa-bb77-cc88-dd99-00ee00ee00ee)
Crear una columna de elección
En el ejemplo siguiente se usan estas propiedades para crear una columna de elección local.
| Las propiedades de PicklistAttributeMetadata | Valores |
|---|---|
SchemaName |
sample_Choice |
DisplayName |
Opción de ejemplo |
Description |
Elegir un atributo |
RequiredLevel |
None |
OptionSet |
value:727000000, label:Bravovalue: 727000001, label:Deltavalue: 727000002, label:Alphavalue: 727000003, label:Charlievalue: 727000004, label:Foxtrot |
En el ejemplo siguiente se crea una columna local con las propiedades y se agrega a la sample_bankaccount tabla.
El URI del atributo se devuelve en la respuesta.
Nota:
Para obtener un ejemplo en el que se muestra cómo crear una columna de elección con un conjunto de opciones global, consulte Creación de una columna de elección mediante un conjunto de opciones global.
Solicitud:
POST [Organization Uri]/api/data/v9.2/EntityDefinitions(LogicalName='sample_bankaccount')/Attributes
MSCRM.SolutionUniqueName: examplesolution
OData-MaxVersion: 4.0
OData-Version: 4.0
If-None-Match: null
Accept: application/json
Content-Type: application/json; charset=utf-8
Content-Length: 4524
{
"@odata.type": "Microsoft.Dynamics.CRM.PicklistAttributeMetadata",
"AttributeType": "Picklist",
"AttributeTypeName": {
"Value": "PicklistType"
},
"SourceTypeMask": 0,
"OptionSet": {
"@odata.type": "Microsoft.Dynamics.CRM.OptionSetMetadata",
"Options": [
{
"Value": 727000000,
"Label": {
"@odata.type": "Microsoft.Dynamics.CRM.Label",
"LocalizedLabels": [
{
"@odata.type": "Microsoft.Dynamics.CRM.LocalizedLabel",
"Label": "Bravo",
"LanguageCode": 1033,
"IsManaged": false
}
],
"UserLocalizedLabel": {
"@odata.type": "Microsoft.Dynamics.CRM.LocalizedLabel",
"Label": "Bravo",
"LanguageCode": 1033,
"IsManaged": false
}
}
},
{
"Value": 727000001,
"Label": {
"@odata.type": "Microsoft.Dynamics.CRM.Label",
"LocalizedLabels": [
{
"@odata.type": "Microsoft.Dynamics.CRM.LocalizedLabel",
"Label": "Delta",
"LanguageCode": 1033,
"IsManaged": false
}
],
"UserLocalizedLabel": {
"@odata.type": "Microsoft.Dynamics.CRM.LocalizedLabel",
"Label": "Delta",
"LanguageCode": 1033,
"IsManaged": false
}
}
},
{
"Value": 727000002,
"Label": {
"@odata.type": "Microsoft.Dynamics.CRM.Label",
"LocalizedLabels": [
{
"@odata.type": "Microsoft.Dynamics.CRM.LocalizedLabel",
"Label": "Alpha",
"LanguageCode": 1033,
"IsManaged": false
}
],
"UserLocalizedLabel": {
"@odata.type": "Microsoft.Dynamics.CRM.LocalizedLabel",
"Label": "Alpha",
"LanguageCode": 1033,
"IsManaged": false
}
}
},
{
"Value": 727000003,
"Label": {
"@odata.type": "Microsoft.Dynamics.CRM.Label",
"LocalizedLabels": [
{
"@odata.type": "Microsoft.Dynamics.CRM.LocalizedLabel",
"Label": "Charlie",
"LanguageCode": 1033,
"IsManaged": false
}
],
"UserLocalizedLabel": {
"@odata.type": "Microsoft.Dynamics.CRM.LocalizedLabel",
"Label": "Charlie",
"LanguageCode": 1033,
"IsManaged": false
}
}
},
{
"Value": 727000004,
"Label": {
"@odata.type": "Microsoft.Dynamics.CRM.Label",
"LocalizedLabels": [
{
"@odata.type": "Microsoft.Dynamics.CRM.LocalizedLabel",
"Label": "Foxtrot",
"LanguageCode": 1033,
"IsManaged": false
}
],
"UserLocalizedLabel": {
"@odata.type": "Microsoft.Dynamics.CRM.LocalizedLabel",
"Label": "Foxtrot",
"LanguageCode": 1033,
"IsManaged": false
}
}
}
],
"IsGlobal": false,
"OptionSetType": "Picklist"
},
"Description": {
"@odata.type": "Microsoft.Dynamics.CRM.Label",
"LocalizedLabels": [
{
"@odata.type": "Microsoft.Dynamics.CRM.LocalizedLabel",
"Label": "Choice Attribute",
"LanguageCode": 1033,
"IsManaged": false
}
],
"UserLocalizedLabel": {
"@odata.type": "Microsoft.Dynamics.CRM.LocalizedLabel",
"Label": "Choice Attribute",
"LanguageCode": 1033,
"IsManaged": false
}
},
"DisplayName": {
"@odata.type": "Microsoft.Dynamics.CRM.Label",
"LocalizedLabels": [
{
"@odata.type": "Microsoft.Dynamics.CRM.LocalizedLabel",
"Label": "Sample Choice",
"LanguageCode": 1033,
"IsManaged": false
}
],
"UserLocalizedLabel": {
"@odata.type": "Microsoft.Dynamics.CRM.LocalizedLabel",
"Label": "Sample Choice",
"LanguageCode": 1033,
"IsManaged": false
}
},
"RequiredLevel": {
"Value": "None",
"CanBeChanged": false,
"ManagedPropertyLogicalName": "canmodifyrequirementlevelsettings"
},
"SchemaName": "sample_Choice"
}
Respuesta:
HTTP/1.1 204 NoContent
OData-Version: 4.0
OData-EntityId: [Organization Uri]/api/data/v9.2/EntityDefinitions(LogicalName='sample_bankaccount')/Attributes(00aa00aa-bb11-cc22-dd33-44ee44ee44ee)
Crear una columna de selección múltiple
En el ejemplo siguiente se usan estas propiedades para crear una columna de selección múltiple local.
| MultiSelectPicklistAttributeMetadata Propiedades | Valores |
|---|---|
SchemaName |
sample_Choice |
DisplayName |
Opción de ejemplo |
Description |
Elegir un atributo |
RequiredLevel |
None |
OptionSet |
value:727000000, label:Aperitivovalue: 727000001, label:Entreevalor: 727000002, etiqueta:Postre |
En el ejemplo siguiente se crea una columna de selección múltiple local mediante las propiedades y se agrega a la sample_bankaccount tabla.
El URI del atributo se devuelve en la respuesta.
Solicitud:
POST [Organization Uri]/api/data/v9.2/EntityDefinitions(LogicalName='sample_bankaccount')/Attributes
MSCRM.SolutionUniqueName: examplesolution
OData-MaxVersion: 4.0
OData-Version: 4.0
If-None-Match: null
Accept: application/json
Content-Type: application/json; charset=utf-8
Content-Length: 3404
{
"@odata.type": "Microsoft.Dynamics.CRM.MultiSelectPicklistAttributeMetadata",
"AttributeType": "Virtual",
"AttributeTypeName": {
"Value": "MultiSelectPicklistType"
},
"SourceTypeMask": 0,
"OptionSet": {
"@odata.type": "Microsoft.Dynamics.CRM.OptionSetMetadata",
"Options": [
{
"Value": 727000000,
"Label": {
"@odata.type": "Microsoft.Dynamics.CRM.Label",
"LocalizedLabels": [
{
"@odata.type": "Microsoft.Dynamics.CRM.LocalizedLabel",
"Label": "Appetizer",
"LanguageCode": 1033,
"IsManaged": false
}
],
"UserLocalizedLabel": {
"@odata.type": "Microsoft.Dynamics.CRM.LocalizedLabel",
"Label": "Appetizer",
"LanguageCode": 1033,
"IsManaged": false
}
}
},
{
"Value": 727000001,
"Label": {
"@odata.type": "Microsoft.Dynamics.CRM.Label",
"LocalizedLabels": [
{
"@odata.type": "Microsoft.Dynamics.CRM.LocalizedLabel",
"Label": "Entree",
"LanguageCode": 1033,
"IsManaged": false
}
],
"UserLocalizedLabel": {
"@odata.type": "Microsoft.Dynamics.CRM.LocalizedLabel",
"Label": "Entree",
"LanguageCode": 1033,
"IsManaged": false
}
}
},
{
"Value": 727000002,
"Label": {
"@odata.type": "Microsoft.Dynamics.CRM.Label",
"LocalizedLabels": [
{
"@odata.type": "Microsoft.Dynamics.CRM.LocalizedLabel",
"Label": "Dessert",
"LanguageCode": 1033,
"IsManaged": false
}
],
"UserLocalizedLabel": {
"@odata.type": "Microsoft.Dynamics.CRM.LocalizedLabel",
"Label": "Dessert",
"LanguageCode": 1033,
"IsManaged": false
}
}
}
],
"IsGlobal": false,
"OptionSetType": "Picklist"
},
"Description": {
"@odata.type": "Microsoft.Dynamics.CRM.Label",
"LocalizedLabels": [
{
"@odata.type": "Microsoft.Dynamics.CRM.LocalizedLabel",
"Label": "MultiSelect Choice Attribute",
"LanguageCode": 1033,
"IsManaged": false
}
],
"UserLocalizedLabel": {
"@odata.type": "Microsoft.Dynamics.CRM.LocalizedLabel",
"Label": "MultiSelect Choice Attribute",
"LanguageCode": 1033,
"IsManaged": false
}
},
"DisplayName": {
"@odata.type": "Microsoft.Dynamics.CRM.Label",
"LocalizedLabels": [
{
"@odata.type": "Microsoft.Dynamics.CRM.LocalizedLabel",
"Label": "Sample MultiSelect Choice",
"LanguageCode": 1033,
"IsManaged": false
}
],
"UserLocalizedLabel": {
"@odata.type": "Microsoft.Dynamics.CRM.LocalizedLabel",
"Label": "Sample MultiSelect Choice",
"LanguageCode": 1033,
"IsManaged": false
}
},
"RequiredLevel": {
"Value": "None",
"CanBeChanged": false,
"ManagedPropertyLogicalName": "canmodifyrequirementlevelsettings"
},
"SchemaName": "sample_MultiSelectChoice"
}
Respuesta:
HTTP/1.1 204 NoContent
OData-Version: 4.0
OData-EntityId: [Organization Uri]/api/data/v9.2/EntityDefinitions(LogicalName='sample_bankaccount')/Attributes(11bb11bb-cc22-dd33-ee44-55ff55ff55ff)
Crea una columna de entero grande
En el ejemplo siguiente se usan estas propiedades para crear una columna de entero grande.
| Propiedades de BigIntAttributeMetadata | Valores |
|---|---|
SchemaName |
sample_BigInt |
DisplayName |
Un ejemplo de BigInt |
Description |
Atributo BigInt |
RequiredLevel |
None |
En el ejemplo siguiente se crea una columna entera con las propiedades y se agrega a la sample_bankaccount tabla.
El URI de la columna se devuelve en la respuesta.
Solicitud
POST [Organization Uri]/api/data/v9.2/EntityDefinitions(LogicalName='sample_bankaccount')/Attributes
MSCRM.SolutionUniqueName: examplesolution
OData-MaxVersion: 4.0
OData-Version: 4.0
If-None-Match: null
Accept: application/json
Authorization: Bearer <access token>
Content-Type: application/json; charset=utf-8
Content-Length: 1301
{
"AttributeType": "BigInt",
"AttributeTypeName": {
"Value": "BigIntType"
},
"@odata.type": "Microsoft.Dynamics.CRM.BigIntAttributeMetadata",
"Description": {
"@odata.type": "Microsoft.Dynamics.CRM.Label",
"LocalizedLabels": [
{
"@odata.type": "Microsoft.Dynamics.CRM.LocalizedLabel",
"Label": "BigInt Attribute",
"LanguageCode": 1033,
"IsManaged": false
}
],
"UserLocalizedLabel": {
"@odata.type": "Microsoft.Dynamics.CRM.LocalizedLabel",
"Label": "BigInt Attribute",
"LanguageCode": 1033,
"IsManaged": false
}
},
"DisplayName": {
"@odata.type": "Microsoft.Dynamics.CRM.Label",
"LocalizedLabels": [
{
"@odata.type": "Microsoft.Dynamics.CRM.LocalizedLabel",
"Label": "Sample BigInt",
"LanguageCode": 1033,
"IsManaged": false
}
],
"UserLocalizedLabel": {
"@odata.type": "Microsoft.Dynamics.CRM.LocalizedLabel",
"Label": "Sample BigInt",
"LanguageCode": 1033,
"IsManaged": false
}
},
"RequiredLevel": {
"Value": "None",
"CanBeChanged": false,
"ManagedPropertyLogicalName": "canmodifyrequirementlevelsettings"
},
"SchemaName": "sample_BigInt"
}
Respuesta
HTTP/1.1 204 NoContent
OData-Version: 4.0
OData-EntityId: [Organization Uri]/api/data/v9.2/EntityDefinitions(LogicalName='sample_bankaccount')/Attributes(22cc22cc-dd33-ee44-ff55-66aa66aa66aa)
Actualización de una columna
Como se mencionó en Actualizar definiciones de tabla, las entidades del modelo de datos se actualizan mediante el método HTTP PUT con toda la definición JSON del elemento actual. Este patrón se aplica a los atributos y las entidades. Al igual que con las entidades, puede sobrescribir etiquetas utilizando el encabezado MSCRM.MergeLabels con el valor establecido en false. Además, debe publicar las personalizaciones antes de que estén activas en el sistema.
Con el atributo booleano creado en Crear una columna booleana anterior, primero debemos recuperar todo el atributo.
Solicitud:
GET [Organization Uri]/api/data/v9.2/EntityDefinitions(LogicalName='new_bankaccount')/Attributes(LogicalName='new_boolean')/Microsoft.Dynamics.CRM.BooleanAttributeMetadata HTTP/1.1
OData-MaxVersion: 4.0
OData-Version: 4.0
If-None-Match: null
Accept: application/json
Respuesta:
HTTP/1.1 OK
OData-Version: 4.0
{
"@odata.context": "[Organization Uri]/api/data/v9.2/$metadata#EntityDefinitions('new_bankaccount')/Attributes/Microsoft.Dynamics.CRM.BooleanAttributeMetadata/$entity",
"MetadataId": "33dd33dd-ee44-ff55-aa66-77bb77bb77bb",
"HasChanged": null,
"AttributeOf": null,
"AttributeType": "Boolean",
"ColumnNumber": 35,
"DeprecatedVersion": null,
"IntroducedVersion": "1.0.0.0",
"EntityLogicalName": "new_bankaccount",
"IsCustomAttribute": true,
"IsPrimaryId": false,
"IsValidODataAttribute": true,
"IsPrimaryName": false,
"IsValidForCreate": true,
"IsValidForRead": true,
"IsValidForUpdate": true,
"CanBeSecuredForRead": true,
"CanBeSecuredForCreate": true,
"CanBeSecuredForUpdate": true,
"IsSecured": false,
"IsRetrievable": false,
"IsFilterable": false,
"IsSearchable": false,
"IsManaged": false,
"LinkedAttributeId": null,
"LogicalName": "new_boolean",
"IsValidForForm": true,
"IsRequiredForForm": false,
"IsValidForGrid": true,
"SchemaName": "new_Boolean",
"ExternalName": null,
"IsLogical": false,
"IsDataSourceSecret": false,
"InheritsFrom": null,
"CreatedOn": "2022-08-08T22:19:49Z",
"ModifiedOn": "2022-08-08T22:19:49Z",
"SourceType": 0,
"AutoNumberFormat": null,
"DefaultValue": false,
"FormulaDefinition": "",
"SourceTypeMask": 0,
"AttributeTypeName": {
"Value": "BooleanType"
},
"Description": {
"LocalizedLabels": [
{
"Label": "Boolean Attribute",
"LanguageCode": 1033,
"IsManaged": false,
"MetadataId": "2b5545d2-a59b-4503-8846-95665283b41f",
"HasChanged": null
}
],
"UserLocalizedLabel": {
"Label": "Boolean Attribute",
"LanguageCode": 1033,
"IsManaged": false,
"MetadataId": "2b5545d2-a59b-4503-8846-95665283b41f",
"HasChanged": null
}
},
"DisplayName": {
"LocalizedLabels": [
{
"Label": "Sample Boolean",
"LanguageCode": 1033,
"IsManaged": false,
"MetadataId": "e6b8d06c-067e-4ab0-a9a8-32f520b25e36",
"HasChanged": null
}
],
"UserLocalizedLabel": {
"Label": "Sample Boolean",
"LanguageCode": 1033,
"IsManaged": false,
"MetadataId": "e6b8d06c-067e-4ab0-a9a8-32f520b25e36",
"HasChanged": null
}
},
"IsAuditEnabled": {
"Value": true,
"CanBeChanged": true,
"ManagedPropertyLogicalName": "canmodifyauditsettings"
},
"IsGlobalFilterEnabled": {
"Value": false,
"CanBeChanged": true,
"ManagedPropertyLogicalName": "canmodifyglobalfiltersettings"
},
"IsSortableEnabled": {
"Value": false,
"CanBeChanged": true,
"ManagedPropertyLogicalName": "canmodifyissortablesettings"
},
"IsCustomizable": {
"Value": true,
"CanBeChanged": true,
"ManagedPropertyLogicalName": "iscustomizable"
},
"IsRenameable": {
"Value": true,
"CanBeChanged": true,
"ManagedPropertyLogicalName": "isrenameable"
},
"IsValidForAdvancedFind": {
"Value": true,
"CanBeChanged": true,
"ManagedPropertyLogicalName": "canmodifysearchsettings"
},
"RequiredLevel": {
"Value": "None",
"CanBeChanged": false,
"ManagedPropertyLogicalName": "canmodifyrequirementlevelsettings"
},
"CanModifyAdditionalSettings": {
"Value": true,
"CanBeChanged": true,
"ManagedPropertyLogicalName": "canmodifyadditionalsettings"
},
"Settings": []
}
A continuación, cambie las propiedades que desea cambiar.
| Propiedades de BooleanAttributeMetadata | Valores antiguos | Nuevos valores |
|---|---|---|
DisplayName |
Boolean de ejemplo | Ejemplo de Boolean actualizado |
Description |
Atributo booleano | Atributo booleano actualizado |
RequiredLevel |
None |
ApplicationRequired |
Nota:
Si desea actualizar las opciones, debe enviar una solicitud diferente. Más información: Opciones de actualización.
Ahora puede enviar la PUT solicitud con las propiedades modificadas:
Solicitud:
PUT [Organization Uri]/api/data/v9.2/EntityDefinitions(LogicalName='new_bankaccount')/Attributes(LogicalName='new_boolean') HTTP/1.1
MSCRM.SolutionUniqueName: examplesolution
MSCRM.MergeLabels: true
OData-MaxVersion: 4.0
OData-Version: 4.0
If-None-Match: null
Accept: application/json
{
"@odata.type": "Microsoft.Dynamics.CRM.BooleanAttributeMetadata",
"MetadataId": "e160ff9b-6f17-ed11-b83e-00224837179f",
"HasChanged": null,
"AttributeOf": null,
"AttributeType": "Boolean",
"ColumnNumber": 35,
"DeprecatedVersion": null,
"IntroducedVersion": "1.0.0.0",
"EntityLogicalName": "new_bankaccount",
"IsCustomAttribute": true,
"IsPrimaryId": false,
"IsValidODataAttribute": true,
"IsPrimaryName": false,
"IsValidForCreate": true,
"IsValidForRead": true,
"IsValidForUpdate": true,
"CanBeSecuredForRead": true,
"CanBeSecuredForCreate": true,
"CanBeSecuredForUpdate": true,
"IsSecured": false,
"IsRetrievable": false,
"IsFilterable": false,
"IsSearchable": false,
"IsManaged": false,
"LinkedAttributeId": null,
"LogicalName": "new_boolean",
"IsValidForForm": true,
"IsRequiredForForm": false,
"IsValidForGrid": true,
"SchemaName": "new_Boolean",
"ExternalName": null,
"IsLogical": false,
"IsDataSourceSecret": false,
"InheritsFrom": null,
"CreatedOn": "2022-08-08T23:12:55Z",
"ModifiedOn": "2022-08-08T23:12:55Z",
"SourceType": 0,
"AutoNumberFormat": null,
"DefaultValue": false,
"FormulaDefinition": "",
"SourceTypeMask": 0,
"AttributeTypeName": {
"Value": "BooleanType"
},
"Description": {
"LocalizedLabels": [
{
"Label": "Boolean Attribute Updated",
"LanguageCode": 1033,
"IsManaged": false,
"MetadataId": "b370f0dd-329f-434e-8b9f-b6eb47d0141f",
"HasChanged": null
}
],
"UserLocalizedLabel": {
"Label": "Boolean Attribute Updated",
"LanguageCode": 1033,
"IsManaged": false,
"MetadataId": "b370f0dd-329f-434e-8b9f-b6eb47d0141f",
"HasChanged": null
}
},
"DisplayName": {
"LocalizedLabels": [
{
"Label": "Sample Boolean Updated",
"LanguageCode": 1033,
"IsManaged": false,
"MetadataId": "63a9e5f1-e730-40cb-a410-495367d5856d",
"HasChanged": null
}
],
"UserLocalizedLabel": {
"Label": "Sample Boolean Updated",
"LanguageCode": 1033,
"IsManaged": false,
"MetadataId": "63a9e5f1-e730-40cb-a410-495367d5856d",
"HasChanged": null
}
},
"IsAuditEnabled": {
"Value": true,
"CanBeChanged": true,
"ManagedPropertyLogicalName": "canmodifyauditsettings"
},
"IsGlobalFilterEnabled": {
"Value": false,
"CanBeChanged": true,
"ManagedPropertyLogicalName": "canmodifyglobalfiltersettings"
},
"IsSortableEnabled": {
"Value": false,
"CanBeChanged": true,
"ManagedPropertyLogicalName": "canmodifyissortablesettings"
},
"IsCustomizable": {
"Value": true,
"CanBeChanged": true,
"ManagedPropertyLogicalName": "iscustomizable"
},
"IsRenameable": {
"Value": true,
"CanBeChanged": true,
"ManagedPropertyLogicalName": "isrenameable"
},
"IsValidForAdvancedFind": {
"Value": true,
"CanBeChanged": true,
"ManagedPropertyLogicalName": "canmodifysearchsettings"
},
"RequiredLevel": {
"Value": "ApplicationRequired",
"CanBeChanged": false,
"ManagedPropertyLogicalName": "canmodifyrequirementlevelsettings"
},
"CanModifyAdditionalSettings": {
"Value": true,
"CanBeChanged": true,
"ManagedPropertyLogicalName": "canmodifyadditionalsettings"
},
"Settings": []
}
Respuesta:
HTTP/1.1 NoContent
OData-Version: 4.0
OData-EntityId: [Organization Uri]/api/data/v9.2/EntityDefinitions(LogicalName='new_bankaccount')/Attributes(LogicalName='new_boolean')
Consulte también
Uso de la API web con metadatos de Microsoft Dataverse
Crear y actualizar definiciones de tabla mediante la API web
Consultar definiciones de tabla con la API web
Recuperar definiciones de tabla por nombre o MetadataId
Modelar relaciones de tabla mediante la API web
Trabajar con definiciones de tabla mediante el SDK para .NET
Definiciones de columna (atributo)
Ejemplo de operaciones de esquema de tabla de API web
Ejemplo de operaciones de esquema de tabla de API web (C#)