Web API를 사용하여 엔터티 정의 만들기 및 업데이트

 

게시 날짜: 2017년 1월

적용 대상: Dynamics 365 (online), Dynamics 365 (on-premises), Dynamics CRM 2016, Dynamics CRM Online

조직 서비스로 모델 엔터티에 대해 할 수 있는 모든 동일한 작업을 수행할 수 있습니다. 이 항목에서는 웹 API를 사용하여 메타데이터 엔터티 작업하기에 중점을 둡니다. 엔터티 메타데이터 속성에 대한 자세한 내용을 찾으려면, Customize 엔터티 메타데이터EntityMetadata EntityType을 참조하십시오.

이 항목의 내용

엔터티 만들기

업데이트 엔터티

특성 만들기

엔터티 만들기

엔터티를 만들려면, POSTJSON 엔터티 데이터의 표현에서 EntityDefinitions 엔터티 설정 경로. 엔터티는 엔터티의 기본 이름 특성에 대한 정의가 포함되어야 합니다. 모든 속성의 값을 설정할 필요가 없습니다. 비록 설명을 설정하는 것이 권장되는 모범 사례이지만, Description를 제외한 이 목록에 있는 항목이 필요합니다. 속성 값을 지정하지 않으면 기본값으로 설정됩니다. 기본 값을 이해하려면, 업데이트 엔터티 섹션에 있는 예제를 보십시오. 이 항목의 예제는 다음과 같은 엔터티 속성을 사용합니다.

엔터티 속성

SchemaName

new_BankAccount

참고

솔루션 게시자와 일치하는 사용자 지정 접두사를 포함해야 합니다. 여기에는 기본값 "new_"가 사용되었지만, 당신은 솔루션에 작동하는 접두사를 선택해야 합니다.

DisplayName

은행 거래처

DisplayCollectionName

은행 거래처

Description

고객의 은행 계좌에 대한 정보를 저장하는 엔티티.

OwnershipType

UserOwned

참고

여기서 값을 설정할 수 있습니다, OwnershipTypes EnumType를 참조하십시오.

IsActivity

false

HasActivities

false

HasNotes

false

이전에 나열된 속성 외에, EntityMetadataAttributes 속성은 초기 엔터티에 대한 초기 이름 특성을 나타내기 위해 StringAttributeMetadata EntityType 하나를 포함하는 배열을 포함해야 합니다. 특성 IsPrimaryName 속성은 true여야 합니다. 다음 표는 예제로 속성 설정을 설명합니다.

기본 특성 속성

SchemaName

new_AccountName

RequiredLevel

None

참고

여기서 값을 설정할 수 있습니다, AttributeRequiredLevelManagedProperty ComplexTypeAttributeRequiredLevel EnumType를 참조하십시오.

MaxLength

100

FormatName

Text

참고

기본 이름 특성은 Text 형식을 사용해야 합니다. 다른 문자열 속성에 사용할 수 있는 형식 옵션은, StringAttributeMetadata 형식을 참조하십시오.

DisplayName

거래처 이름

Description

은행 거래처의 이름을 입력합니다.

IsPrimaryName

true

참고

Label ComplexType를 사용하여 레이블을 생성하거나 업데이트하는 경우, LocalizedLabels 속성만 설정하면 됩니다.UserLocalizedLabel 반환 값은 사용자의 언어 기본 설정을 기반으로하며 읽기 전용입니다.

다음 예제에서는 사용자 지정 속성 집합을 사용한 엔터티 생성을 보여줍니다. 언어는 1033의 로캘 ID (LCID)를 사용하는 영어입니다.유효한 로캘 ID 값은 LCID(로캘 ID) 차트에서 확인할 수 있습니다.

  • 요청

    POST cc_WebAPI_ServiceURI/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: cc_WebAPI_ServiceURI/EntityDefinitions(417129e1-207c-e511-80d2-00155d2a68d2)
    

업데이트 엔터티

중요

모델 엔터티를 업데이트하기 위해 HTTP PATCH 메서드를 사용할 수 없습니다. 메타 데이터 엔터티는 포함된 엔터티 정의를 대체하는 조직 서비스 UpdateEntityRequest를 사용하는 패리티를 가지고 있습니다. 따라서, 업데이트할 때는 HTTP PUT 메서드를 사용해야하며 변경할 의도가 없는 모든 현존하는 속성을 포함하도록 주의를 기울여야 합니다. 개별 속성을 업데이트할 수 없습니다.

레이블로 메타 데이터를 업데이트하는 경우, 사용자 지정 MSCRM.MergeLabels 헤더를 포함하여 업데이트에 있는 레이블이 처리되어야 하는 방식을 컨트롤할 수 있습니다. 항목에 대한 레이블이 이비 다른 언어에 대한 레이블을 가지고 있으며 특정 언어에 대한 하나의 레이블만 포함하는 레이블로 이를 업데이트 한다면, MSCRM.MergeLabels 헤더가 현재 레이블에 덮어쓰기를 할지, 현재 언어 레이블과 새로운 레이블을 병합할지 컨트롤합니다.MSCRM.MergeLabels를 사용하여 true로 설정, 정의된 새로운 레이블은 언어 코드가 일치 하는 경우에 기존 레이블을 덮어쓰게 됩니다. 포함시킨 레이블만 포함하도록 현재 레이블을 덮어쓰기 하려면, MSCRM.MergeLabelsfalse로 설정하십시오.

중요

MSCRM.MergeLabels 헤더를 포함하지 않으면, 기본 동작은 마치 값이 false 이었던 것처럼 되고 업데이트에 포함되지 않은 지역화된 레이블은 손실됩니다.

엔터티 또는 특성을 업데이트하는 경우, PublishXml Action 또는 PublishAllXml Action를 변경 내용이 응용 프로그램에 적용되기 전에 사용해야 합니다.추가 정보:사용자 지정 항목 게시

일반적으로, 특성의 JSON 정의를 검색하고 다시 보내기 전에 해당 속성을 수정합니다. 다음 예제는 예제를 사용하여 엔터티 만들기에서 생성된 엔터티의 모든 메타 데이터 속성을 포함하지만 Bank Business Name로 변경된 DisplayName을 가지고 있습니다. 여기의 JSON이 엔터티 만들기 예제에 설정되지 않은 속성에 대한 기본 값을 제공한다는 사실을 언급하는 게 유용할 수 있습니다.

  • 요청

    PUT cc_WebAPI_ServiceURI/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": "cc_WebAPI_ServiceURI/$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
    

특성 만들기

초기 이름 특성 역할을 하는 문자열 특성에 추가적으로 게시한 엔터티에 대한 Attributes 배열에 있는 특성의 JSON 정의를 포함하므로써 엔터티를 생성하는 시기와 똑같은 시기에 특성을 생성할 수 있습니다. 이미 생성된 엔터티에 특성을 추가하고 싶다면, JSON 정의를 포함하고 있는 POST 요청을 엔터티 Attributes 컬렉션-가치 탐색 속성으로 보낼 수 있습니다.

문자열 특성 만들기

다음 예제에서는 문자열 특성을 만들기 위해 이러한 속성을 사용할 것입니다.

문자열 특성 속성

SchemaName

new_BankName

DisplayName

은행 이름

Description

은행의 이름을 입력합니다.

RequiredLevel

None

MaxLength

100

FormatName

Text

다음 예제는 속성을 사용하는 문자열 특성을 생성하고 이를 402fa40f-287c-e511-80d2-00155d2a68d2의 MetadataId 값을 가지고 있는 엔터티에 추가합니다. 특성에 대한 URI은 응답으로 반환됩니다.

  • 요청

    POST cc_WebAPI_ServiceURI/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: cc_WebAPI_ServiceURI/EntityDefinitions(402fa40f-287c-e511-80d2-00155d2a68d2)/Attributes(f01bef16-287c-e511-80d2-00155d2a68d2)
    

머니 특성 만들기

다음 예제에서는 머니 특성을 만들기 위해 이러한 속성을 사용할 것입니다.

머니 특성 속성

SchemaName

new_Balance

DisplayName

잔액

Description

잔액을 입력합니다.

RequiredLevel

None

PrecisionSource

2

참고

PrecisionSource 유효 값에 대한 자세한 내용은 수량 데이터 특성 를 참조하십시오. 값이 2라는 것은 소수점 정밀도가 TransactionCurrency에 맞다는 의미입니다. CurrencyPrecision는 현제 레코드와 연관되어 있습니다.

다음 예시는 속성을 사용하여 돈 특성을 생성하며 이를 402fa40f-287c-e511-80d2-00155d2a68d2의 MetadataId 값을 가지고 있는 엔터티에 추가합니다. 특성에 대한 URI은 응답으로 반환됩니다.

  • 요청

    POST cc_WebAPI_ServiceURI/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: cc_WebAPI_ServiceURI/EntityDefinitions(402fa40f-287c-e511-80d2-00155d2a68d2)/Attributes(f11bef16-287c-e511-80d2-00155d2a68d2)
    

datetime 특성 만들기

다음 예제에서는 datetime 특성을 만들기 위해 이러한 속성을 사용할 것입니다.

Datetime 특성 속성

SchemaName

new_Checkeddate

DisplayName

날짜

Description

계정 잔액 날짜는 마지막에 확인되었습니다.

RequiredLevel

없음

Format

날짜만

참고

이 속성에 대한 유효한 옵션은, DateTimeFormat EnumType을 참조하십시오.

다음 예제는 속성을 사용하는 날짜시간 특성을 생성하고 이를 402fa40f-287c-e511-80d2-00155d2a68d2의 MetadataId 값을 가지고 있는 엔터티에 추가합니다. 특성에 대한 URI은 응답으로 반환됩니다.

  • 요청

    POST cc_WebAPI_ServiceURI/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: cc_WebAPI_ServiceURI/EntityDefinitions(402fa40f-287c-e511-80d2-00155d2a68d2)/Attributes(fe1bef16-287c-e511-80d2-00155d2a68d2)
    

고객 조회 특성 만들기

다른 특성과 달리 고객 조회 특성은 CreateCustomerRelationships 동작을 사용하여 생성됩니다. 이 작업에 대한 매개 변수에는 조회 특성 및 한 쌍의 일대다 관계 정의가 필요합니다. 고객 조회 특성은 두 개의 일대다 관계를 가집니다. 하나는 거래처 엔터티, 다른 하나는 연락처 엔터티에 대한 관계입니다.

다음 예제에서는 고객 조회 특성을 만들기 위해 이러한 속성을 사용할 것입니다.

고객 조회 특성 속성

SchemaName

new_CustomerId

DisplayName

고객

Description

샘플 고객 조회 특성

예제에서는 고객 조회 특성 new_CustomerId를 만들고 사용자 지정 엔터티 new_bankaccount에 추가합니다. 응답은 CreateCustomerRelationshipsResponse 복합 형식입니다.

  • Request

    POST 
          [조직 URI]/api/data/v8.2/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"
        }
    }
    
  • Response

    HTTP/1.1 200 OK
    Content-Type: application/json; odata.metadata=minimal
    OData-Version: 4.0
    
    {
        "@odata.context": "
          [조직 URI]/api/data/v8.2/$metadata#Microsoft.Dynamics.CRM.CreateCustomerRelationshipsResponse",
        "RelationshipIds": [
            "a7d261bc-3580-e611-80d7-00155d2a68de", "aed261bc-3580-e611-80d7-00155d2a68de"
        ],
        "AttributeId": "39a5d94c-e8a2-4a41-acc0-8487242d455e"
    }
    

특성 업데이트

업데이트 엔터티에 설명한 것 처럼, 모델 엔티티는 현제 아이템의 전체 JSON 정의로 HTTP PUT 메서드를 사용하여 업데이트 됩니다. 이것은 엔터티와 마찬가지로 특성에 적용됩니다. 엔터티 처럼, MSCRM.MergeLabels 헤더를 사용하여 레이블을 false로 설정된 값으로 덮어쓸 수 있는 옵션을 가지고 있으며 시스템에서 이것이 활성화 되기 전에 사용자 지정을 게시해야 합니다.

참고 항목

웹 API를 Dynamics 365 메타데이터와 함께 사용
웹 API를 사용하는 메타데이터 쿼리
이름 또는 MetadataId로 메타데이터 검색
Web API를 사용하여 엔터티 관계 만들기 및 업데이트
Dynamics 365 메타데이터에서 조직 서비스 사용
Customize 특성 메타데이터 메시지

Microsoft Dynamics 365

© 2017 Microsoft. All rights reserved. 저작권 정보