Web API を使用したテーブル定義の作成および更新
注意
エンティティとテーブルの違いがわかりませんか? Microsoft Dataverse で「開発者: 用語を理解する」を参照してください。
Web API を使ったテーブル定義の操作は、組織サービスと同様に行うことができます。 このトピックでは、Web API 使用したテーブル定義 (メタデータ) の操作に特化して説明します。 テーブル定義のプロパティの詳細については、テーブル定義のカスタマイズ と EntityMetadata EntityType を参照してください。
ヒント
エンティティ、属性、およびグローバル オプション セット (テーブル、列、および選択肢とも呼ばれます) は、すべてソリューション コンポーネントです。 それらを作成する際は、MSCRM.SolutionUniqueName 要求ヘッダーを使ってソリューションに関連付けて、値をソリューションの一意の名前に設定します。
テーブル作成の定義
テーブル定義を作成するには、エンティティ定義データの JSON 表現を、EntityDefinitions エンティティ セット パスに POST します。 エンティティには、プライマリ名属性の定義を含める必要があります。 すべてのプロパティの値を設定する必要はありません。 説明の設定は推奨されるベスト プラクティスですが、このリストの説明以外のアイテムは必須です。 指定しないプロパティ値は既定値に設定されます。 既定の値を理解するには、テーブル定義を更新するセクションに記載の例を参照してください。 このトピックの例では、以下のエンティティ プロパティを使用します。
| EntityMetadata プロパティ | 値 |
|---|---|
| スキーマ名 | new_BankAccount 注: ソリューション発行者に一致するカスタマイズの接頭辞を含める必要があります。 ここでは既定値 "new_" を使用しますが、自分のソリューションに合った接頭辞を選択する必要があります。 |
| DisplayName | 銀行口座 |
| DisplayCollectionName | 銀行口座 |
| 内容 | 顧客の銀行口座に関する情報を格納するエンティティ。 |
| OwnershipType | UserOwned 注: ここで設定することができる値については、OwnershipTypes EnumType を参照してください。 |
| IsActivity | false |
| HasActivities | false |
| HasNotes | false |
前の一覧に示したプロパティのほかに、EntityMetadataAttributes プロパティに、エンティティのプライマリ名属性を表す StringAttributeMetadata EntityType を 1 つ含む配列を含める必要があります。 IsPrimaryName プロパティは true である必要があります。 次の表では、例で設定するプロパティについて説明します。
| 主属性プロパティ | Value |
|---|---|
| SchemaName | new_AccountName |
| RequiredLevel | なし 注意: ここに設定できる値については、AttributeRequiredLevelManagedProperty ComplexTypeおよびAttributeRequiredLevel EnumTypeを参照してください。 |
| MaxLength | 100 |
| FormatName | Text 注意: プライマリ名属性はテキスト形式を使用する必要があります。 他の文字列属性で使用できる書式オプションについては、文字列書式を参照してください。 |
| DisplayName | 取引先企業名 |
| 説明 | 銀行口座の名前を入力します。 |
| IsPrimaryName | True |
注意
Label ComplexType を使用してラベルを作成または更新するとき、LocalizedLabels プロパティのみを設定する必要があります。 返される UserLocalizedLabel 値は、ユーザーの言語設定に基づき、かつ読み取り専用です。
次の例は、プロパティが設定されたカスタムテーブルの作成を示しています。 言語は、ロケール ID (LCID) が 1033 である英語です。 有効なロケール ID 値は、ロケール ID (LCID) の一覧のページで確認できます。
要求
POST [Organization URI]/api/data/v9.0/EntityDefinitions HTTP/1.1
Accept: application/json
Content-Type: application/json; charset=utf-8
OData-MaxVersion: 4.0
OData-Version: 4.0
{
"@odata.type": "Microsoft.Dynamics.CRM.EntityMetadata",
"Attributes": [
{
"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 account",
"LanguageCode": 1033
}
]
},
"DisplayName": {
"@odata.type": "Microsoft.Dynamics.CRM.Label",
"LocalizedLabels": [
{
"@odata.type": "Microsoft.Dynamics.CRM.LocalizedLabel",
"Label": "Account Name",
"LanguageCode": 1033
}
]
},
"IsPrimaryName": true,
"RequiredLevel": {
"Value": "None",
"CanBeChanged": true,
"ManagedPropertyLogicalName": "canmodifyrequirementlevelsettings"
},
"SchemaName": "new_AccountName",
"@odata.type": "Microsoft.Dynamics.CRM.StringAttributeMetadata",
"FormatName": {
"Value": "Text"
},
"MaxLength": 100
}
],
"Description": {
"@odata.type": "Microsoft.Dynamics.CRM.Label",
"LocalizedLabels": [
{
"@odata.type": "Microsoft.Dynamics.CRM.LocalizedLabel",
"Label": "An entity to store information about customer bank accounts",
"LanguageCode": 1033
}
]
},
"DisplayCollectionName": {
"@odata.type": "Microsoft.Dynamics.CRM.Label",
"LocalizedLabels": [
{
"@odata.type": "Microsoft.Dynamics.CRM.LocalizedLabel",
"Label": "Bank Accounts",
"LanguageCode": 1033
}
]
},
"DisplayName": {
"@odata.type": "Microsoft.Dynamics.CRM.Label",
"LocalizedLabels": [
{
"@odata.type": "Microsoft.Dynamics.CRM.LocalizedLabel",
"Label": "Bank Account",
"LanguageCode": 1033
}
]
},
"HasActivities": false,
"HasNotes": false,
"IsActivity": false,
"OwnershipType": "UserOwned",
"SchemaName": "new_BankAccount"
}
回答
HTTP/1.1 204 No Content
OData-Version: 4.0
OData-EntityId: [Organization URI]/api/data/v9.0/EntityDefinitions(417129e1-207c-e511-80d2-00155d2a68d2)
テーブル更新の定義
重要
HTTPPATCH メソッドを使用してデータ モデル エンティティを更新することはできません。 テーブルの定義は、エンティティの定義を含むものに置き換える組織サービスの UpdateEntityRequest と同等です。 そのため、データモデルのエンティティを更新する際には、HTTP PUT メソッドを使用し、変更予定のない既存のプロパティをすべて含めるように注意する必要があります。 個々のプロパティを更新することはできません。
ラベルを使用してテーブル定義を更新する場合は、カスタム MSCRM.MergeLabels ヘッダーを含めて、更新中のラベルをどのように処理するかを制御する必要があります。 任意のアイテムのラベルにほかの言語のラベルが含まれていて、そのラベルを特定の言語のラベルのみを含むラベルに更新する場合、MSCRM.MergeLabels ヘッダーは、既存のラベルを上書きするか、または既存の言語のラベルに新しいラベルを統合するかを制御します。 MSCRM.MergeLabels を true に設定した場合、言語コードが一致するときだけ、定義した新しいラベルが既存のラベルに上書きされます。 組み込んだラベルのみが組み込まれるように既存のラベルを上書きする場合は、MSCRM.MergeLabels を false に設定します。
重要
MSCRM.MergeLabels ヘッダーを組み込まない場合、既定では、この値が false であるものとして動作し、更新プログラムに含まれていないローカライズされたラベルは失われます。
テーブルや列の定義を更新した場合、変更内容がアプリケーションに適用される前に、PublishXml Action または PublishAllXml Action を使用する必要があります。 詳細: カスタマイズの公開
一般的には、エンティティ属性の JSON 定義を取得し、プロパティを変更してから送信します。 次の例では、テーブル定義を作成する の例で作成したテーブルのすべての定義プロパティが含まれていますが、DisplayName を 「銀行のビジネス名」 に変更しています。 ここでの JSON は、テーブル定義を作成する の例で設定されていないプロパティの既定値を提供していることを知っておくとよいでしょう。
要求
PUT [Organization URI]/api/data/v9.0/EntityDefinitions(417129e1-207c-e511-80d2-00155d2a68d2) HTTP/1.1
Accept: application/json
Content-Type: application/json; charset=utf-8
OData-MaxVersion: 4.0
OData-Version: 4.0
MSCRM.MergeLabels: true
{
"@odata.context": "[Organization URI]/api/data/v9.0/$metadata#EntityDefinitions/$entity",
"ActivityTypeMask": 0,
"AutoRouteToOwnerQueue": false,
"CanTriggerWorkflow": true,
"Description": {
"LocalizedLabels": [
{
"Label": "An entity to store information about customer bank accounts",
"LanguageCode": 1033,
"IsManaged": false,
"MetadataId": "edc3abd7-c5ae-4822-a3ed-51734fdd0469",
"HasChanged": null
}
]
},
"DisplayCollectionName": {
"LocalizedLabels": [
{
"Label": "Bank Accounts",
"LanguageCode": 1033,
"IsManaged": false,
"MetadataId": "7c758e0c-e9cf-4947-93b0-50ec30b20f60",
"HasChanged": null
}
]
},
"DisplayName": {
"@odata.type": "Microsoft.Dynamics.CRM.Label",
"LocalizedLabels": [
{
"@odata.type": "Microsoft.Dynamics.CRM.LocalizedLabel",
"Label": "Bank Business Name",
"LanguageCode": 1033
}
]
},
"EntityHelpUrlEnabled": false,
"EntityHelpUrl": null,
"IsDocumentManagementEnabled": false,
"IsOneNoteIntegrationEnabled": false,
"IsInteractionCentricEnabled": false,
"IsKnowledgeManagementEnabled": false,
"AutoCreateAccessTeams": false,
"IsActivity": false,
"IsActivityParty": false,
"IsAuditEnabled": {
"Value": false,
"CanBeChanged": true,
"ManagedPropertyLogicalName": "canmodifyauditsettings"
},
"IsAvailableOffline": false,
"IsChildEntity": false,
"IsAIRUpdated": false,
"IsValidForQueue": {
"Value": false,
"CanBeChanged": true,
"ManagedPropertyLogicalName": "canmodifyqueuesettings"
},
"IsConnectionsEnabled": {
"Value": false,
"CanBeChanged": true,
"ManagedPropertyLogicalName": "canmodifyconnectionsettings"
},
"IconLargeName": null,
"IconMediumName": null,
"IconSmallName": null,
"IsCustomEntity": true,
"IsBusinessProcessEnabled": false,
"IsCustomizable": {
"Value": true,
"CanBeChanged": true,
"ManagedPropertyLogicalName": "iscustomizable"
},
"IsRenameable": {
"Value": true,
"CanBeChanged": true,
"ManagedPropertyLogicalName": "isrenameable"
},
"IsMappable": {
"Value": true,
"CanBeChanged": false,
"ManagedPropertyLogicalName": "ismappable"
},
"IsDuplicateDetectionEnabled": {
"Value": false,
"CanBeChanged": true,
"ManagedPropertyLogicalName": "canmodifyduplicatedetectionsettings"
},
"CanCreateAttributes": {
"Value": true,
"CanBeChanged": false,
"ManagedPropertyLogicalName": "cancreateattributes"
},
"CanCreateForms": {
"Value": true,
"CanBeChanged": true,
"ManagedPropertyLogicalName": "cancreateforms"
},
"CanCreateViews": {
"Value": true,
"CanBeChanged": true,
"ManagedPropertyLogicalName": "cancreateviews"
},
"CanCreateCharts": {
"Value": true,
"CanBeChanged": true,
"ManagedPropertyLogicalName": "cancreatecharts"
},
"CanBeRelatedEntityInRelationship": {
"Value": true,
"CanBeChanged": true,
"ManagedPropertyLogicalName": "canberelatedentityinrelationship"
},
"CanBePrimaryEntityInRelationship": {
"Value": true,
"CanBeChanged": true,
"ManagedPropertyLogicalName": "canbeprimaryentityinrelationship"
},
"CanBeInManyToMany": {
"Value": true,
"CanBeChanged": true,
"ManagedPropertyLogicalName": "canbeinmanytomany"
},
"CanEnableSyncToExternalSearchIndex": {
"Value": true,
"CanBeChanged": true,
"ManagedPropertyLogicalName": "canenablesynctoexternalsearchindex"
},
"SyncToExternalSearchIndex": false,
"CanModifyAdditionalSettings": {
"Value": true,
"CanBeChanged": true,
"ManagedPropertyLogicalName": "canmodifyadditionalsettings"
},
"CanChangeHierarchicalRelationship": {
"Value": true,
"CanBeChanged": true,
"ManagedPropertyLogicalName": "canchangehierarchicalrelationship"
},
"IsOptimisticConcurrencyEnabled": true,
"ChangeTrackingEnabled": false,
"IsImportable": true,
"IsIntersect": false,
"IsMailMergeEnabled": {
"Value": true,
"CanBeChanged": true,
"ManagedPropertyLogicalName": "canmodifymailmergesettings"
},
"IsManaged": false,
"IsEnabledForCharts": true,
"IsEnabledForTrace": false,
"IsValidForAdvancedFind": true,
"IsVisibleInMobile": {
"Value": false,
"CanBeChanged": true,
"ManagedPropertyLogicalName": "canmodifymobilevisibility"
},
"IsVisibleInMobileClient": {
"Value": false,
"CanBeChanged": true,
"ManagedPropertyLogicalName": "canmodifymobileclientvisibility"
},
"IsReadOnlyInMobileClient": {
"Value": false,
"CanBeChanged": true,
"ManagedPropertyLogicalName": "canmodifymobileclientreadonly"
},
"IsOfflineInMobileClient": {
"Value": false,
"CanBeChanged": true,
"ManagedPropertyLogicalName": "canmodifymobileclientoffline"
},
"DaysSinceRecordLastModified": 0,
"IsReadingPaneEnabled": true,
"IsQuickCreateEnabled": false,
"LogicalName": "new_bankaccount",
"ObjectTypeCode": 10009,
"OwnershipType": "UserOwned",
"PrimaryNameAttribute": "new_accountname",
"PrimaryImageAttribute": null,
"PrimaryIdAttribute": "new_bankaccountid",
"Privileges": [
{
"CanBeBasic": true,
"CanBeDeep": true,
"CanBeGlobal": true,
"CanBeLocal": true,
"CanBeEntityReference": false,
"CanBeParentEntityReference": false,
"Name": "prvCreatenew_BankAccount",
"PrivilegeId": "d1a8de4b-27df-42e1-bc5c-b863e002b37f",
"PrivilegeType": "Create"
},
{
"CanBeBasic": true,
"CanBeDeep": true,
"CanBeGlobal": true,
"CanBeLocal": true,
"CanBeEntityReference": false,
"CanBeParentEntityReference": false,
"Name": "prvReadnew_BankAccount",
"PrivilegeId": "726043b1-de2c-487e-9d6d-5629fca2bf22",
"PrivilegeType": "Read"
},
{
"CanBeBasic": true,
"CanBeDeep": true,
"CanBeGlobal": true,
"CanBeLocal": true,
"CanBeEntityReference": false,
"CanBeParentEntityReference": false,
"Name": "prvWritenew_BankAccount",
"PrivilegeId": "fa50c539-b6c7-4eaf-bd49-fd8224bc51b6",
"PrivilegeType": "Write"
},
{
"CanBeBasic": true,
"CanBeDeep": true,
"CanBeGlobal": true,
"CanBeLocal": true,
"CanBeEntityReference": false,
"CanBeParentEntityReference": false,
"Name": "prvDeletenew_BankAccount",
"PrivilegeId": "17c1fd6e-f856-45e7-b563-796f53108b85",
"PrivilegeType": "Delete"
},
{
"CanBeBasic": true,
"CanBeDeep": true,
"CanBeGlobal": true,
"CanBeLocal": true,
"CanBeEntityReference": false,
"CanBeParentEntityReference": false,
"Name": "prvAssignnew_BankAccount",
"PrivilegeId": "133ca81d-668e-4c19-a71e-10c6dfe099cd",
"PrivilegeType": "Assign"
},
{
"CanBeBasic": true,
"CanBeDeep": true,
"CanBeGlobal": true,
"CanBeLocal": true,
"CanBeEntityReference": false,
"CanBeParentEntityReference": false,
"Name": "prvSharenew_BankAccount",
"PrivilegeId": "15f27df4-9c67-47c9-b1f1-274e1c44f24a",
"PrivilegeType": "Share"
},
{
"CanBeBasic": true,
"CanBeDeep": true,
"CanBeGlobal": true,
"CanBeLocal": true,
"CanBeEntityReference": false,
"CanBeParentEntityReference": false,
"Name": "prvAppendnew_BankAccount",
"PrivilegeId": "ac8b1920-8f93-4e9d-94e3-c680e2a2f228",
"PrivilegeType": "Append"
},
{
"CanBeBasic": true,
"CanBeDeep": true,
"CanBeGlobal": true,
"CanBeLocal": true,
"CanBeEntityReference": false,
"CanBeParentEntityReference": false,
"Name": "prvAppendTonew_BankAccount",
"PrivilegeId": "f63a5f46-3bc7-4eac-81d0-7f77f566ef46",
"PrivilegeType": "AppendTo"
}
],
"RecurrenceBaseEntityLogicalName": null,
"ReportViewName": "Filterednew_BankAccount",
"SchemaName": "new_BankAccount",
"IntroducedVersion": "1.0",
"IsStateModelAware": true,
"EnforceStateTransitions": false,
"EntityColor": null,
"LogicalCollectionName": "new_bankaccounts",
"CollectionSchemaName": "new_BankAccounts",
"EntitySetName": "new_bankaccounts",
"IsEnabledForExternalChannels": false,
"IsPrivate": false,
"MetadataId": "417129e1-207c-e511-80d2-00155d2a68d2",
"HasChanged": null
}
回答
HTTP/1.1 204 No Content
OData-Version: 4.0
列を作成する
テーブルのカラム (エンティティの属性) は、プライマリ名属性となる文字列属性に加えて、投稿するエンティティの属性の JSON 定義を Attributes 配列に含めることで、テーブル定義の作成と同時に作成することができます。 既に作成されているエンティティに属性を追加する場合、その属性の JSON 定義を含む POST 要求をエンティティ Attributes のコレクション値ナビゲーション プロパティに送信することができます。
文字列の列を作成する
次の例では、文字列属性の作成に次のプロパティを使用します。
| 文字列属性のプロパティ | 値 |
|---|---|
| SchemaName | new_BankName |
| DisplayName | 銀行名 |
| 内容 | 銀行の名前を入力します。 |
| RequiredLevel | なし |
| MaxLength | 100 |
| FormatName | テキスト |
次の例では、プロパティーを使用して文字列属性を作成し、MetadataId の値である 402fa40f-287c-e511-80d2-00155d2a68d2 とともにエンティティーに追加します。
この属性の URI が応答で返されます。
要求
POST [Organization URI]/api/data/v9.0/EntityDefinitions(402fa40f-287c-e511-80d2-00155d2a68d2)/Attributes HTTP/1.1
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
}
回答
HTTP/1.1 204 No Content
OData-Version: 4.0
OData-EntityId: [Organization URI]/api/data/v9.0/EntityDefinitions(402fa40f-287c-e511-80d2-00155d2a68d2)/Attributes(f01bef16-287c-e511-80d2-00155d2a68d2)
Money 列を作成する
次の例では、通貨属性の作成に次のプロパティを使用します。
| 通貨属性のプロパティ | 値 |
|---|---|
| SchemaName | new_Balance |
| DisplayName | 残高 |
| 内容 | 残高金額を入力します。 |
| RequiredLevel | なし |
| PrecisionSource | 2 注意: PrecisionSource の有効な値については、MoneyTypeを参照してください。 値 2 は、小数点以下の精度のレベルが、現在のレコードに関連付けられている TransactionCurrency.CurrencyPrecision に一致することを意味します。 |
次の例では、プロパティーを使用してマネー属性を作成し、MetadataId の値である 402fa40f-287c-e511-80d2-00155d2a68d2 とともにエンティティーに追加します。 この属性の URI が応答で返されます。
要求
POST [Organization URI]/api/data/v9.0/EntityDefinitions(402fa40f-287c-e511-80d2-00155d2a68d2)/Attributes HTTP/1.1
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
}
回答
HTTP/1.1 204 No Content
OData-Version: 4.0
OData-EntityId: [Organization URI]/api/data/v9.0/EntityDefinitions(402fa40f-287c-e511-80d2-00155d2a68d2)/Attributes(f11bef16-287c-e511-80d2-00155d2a68d2)
datetime 列を作成する
次の例では、日時属性の作成に次のプロパティを使用します。
| 日時属性のプロパティ | 値 |
|---|---|
| SchemaName | new_Checkeddate |
| DisplayName | 日付 |
| 内容 | 勘定残高が最後に確認された日付。 |
| RequiredLevel | なし |
| 書式 | DateOnly 注: このプロパティの有効なオプションについては、DateTimeFormat EnumType を参照してください。 |
次の例では、プロパティーを使用して日付属性を作成し、MetadataId の値である 402fa40f-287c-e511-80d2-00155d2a68d2 とともにエンティティーに追加します。 この属性の URI が応答で返されます。
要求
POST [Organization URI]/api/data/v9.0/EntityDefinitions(402fa40f-287c-e511-80d2-00155d2a68d2)/Attributes HTTP/1.1
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"
}
回答
HTTP/1.1 204 No Content
OData-Version: 4.0
OData-EntityId: [Organization URI]/api/data/v9.0/EntityDefinitions(402fa40f-287c-e511-80d2-00155d2a68d2)/Attributes(fe1bef16-287c-e511-80d2-00155d2a68d2)
顧客検索列を作成する
他の属性とは異なり、顧客検索属性は CreateCustomerRelationships Action を使用して作成されます。
このアクションのパラメーターは、参照属性の種類の定義と 1 組の一対多関連付けを必要とします。 顧客検索属性には複数の一対多関連付けがあります: 1 つは取引先企業エンティティに対して、他方は取引先担当者エンティティに対してです。
次の例では、顧客検索属性の作成に次のプロパティを使用します。
| 顧客検索属性のプロパティ | 値 |
|---|---|
| SchemaName | new_CustomerId |
| DisplayName | Customer |
| 内容 | サンプルの顧客検索属性 |
例では、顧客検索属性、new_CustomerId を作成し、それはユーザー定義エンティティ、new_bankaccount に追加されます。 応答は CreateCustomerRelationshipsResponse ComplexType です。
要求
POST [Organization URI]/api/data/v9.0/CreateCustomerRelationships HTTP/1.1
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"
}
}
回答
HTTP/1.1 200 OK
Content-Type: application/json; odata.metadata=minimal
OData-Version: 4.0
{
"@odata.context": "[Organization URI]/api/data/v9.0/$metadata#Microsoft.Dynamics.CRM.CreateCustomerRelationshipsResponse",
"RelationshipIds": [
"a7d261bc-3580-e611-80d7-00155d2a68de", "aed261bc-3580-e611-80d7-00155d2a68de"
],
"AttributeId": "39a5d94c-e8a2-4a41-acc0-8487242d455e"
}
列の更新
テーブル定義を更新するで説明しているとおり、データモデル エンティティは、現在のアイテムの JSON 定義全体で HTTPPUT メソッドを使用して更新されます。 これは、エンティティだけでなくエンティティ属性にも適用されます。 エンティティの場合とまったく同様に、値が false に設定された MSCRM.MergeLabels ヘッダーを使用してラベルを上書きすることが可能であり、カスタマイズがシステムでアクティブになる前にそのカスタマイズを公開する必要があります。
関連項目
Microsoft Dataverse メタデータで Web API を使用する
Web API を使用したテーブル定義のクエリ
名前または MetadataId によるテーブル定義を取得する
WebAPI を使用したモデル テーブル リレーションシップ
組織サービスによるテーブル定義の操作
属性 (属性) の定義
注意
ドキュメントの言語設定についてお聞かせください。 簡単な調査を行います。 (この調査は英語です)
この調査には約 7 分かかります。 個人データは収集されません (プライバシー ステートメント)。
フィードバック
フィードバックの送信と表示