사용자 지정 엔터티 만들기

 

게시 날짜: 2017년 1월

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

이 항목에서는 은행 계좌라는 사용자 지정 사용자 담당 엔터티를 만들고 네 가지 다른 유형의 특성을 추가하는 방법을 보여 줍니다.

조직 담당 사용자 지정 엔터티를 만들 수도 있습니다.추가 정보:엔터티 소유권 형태

참고

엔터티 속성이 이 엔터티가 표시되는 영역을 설정하기 위해 편집되고 설정되지 않은 경우 응용 프로그램 탐색에서 이 엔터티를 볼 수 없습니다.

이 항목의 내용

사용자 지정 엔터티 만들기

사용자 지정 엔터티에 문자열 특성 추가

사용자 지정 엔터티에 금액 특성 추가

사용자 지정 엔터티에 DateTime 특성 추가

사용자 지정 엔터티에 조회 특성 추가

사용자 지정 엔터티 만들기

다음 샘플은 CreateEntityRequest을 사용하여 엔터티와 StringAttributeMetadataPrimaryAttribute를 생성합니다.

_customEntityName 값은 “new_bankaccount”입니다.


CreateEntityRequest createrequest = new CreateEntityRequest
{

 //Define the entity
 Entity = new EntityMetadata
 {
  SchemaName = _customEntityName,
  DisplayName = new Label("Bank Account", 1033),
  DisplayCollectionName = new Label("Bank Accounts", 1033),
  Description = new Label("An entity to store information about customer bank accounts", 1033),
  OwnershipType = OwnershipTypes.UserOwned,
  IsActivity = false,

 },

 // Define the primary attribute for the entity
 PrimaryAttribute = new StringAttributeMetadata
 {
  SchemaName = "new_accountname",
  RequiredLevel = new AttributeRequiredLevelManagedProperty(AttributeRequiredLevel.None),
  MaxLength = 100,
  FormatName = StringFormatName.Text,
  DisplayName = new Label("Account Name", 1033),
  Description = new Label("The primary attribute for the Bank Account entity.", 1033)
 }

};
_serviceProxy.Execute(createrequest);
Console.WriteLine("The bank account entity has been created.");

Dim createrequest As CreateEntityRequest = New CreateEntityRequest With {
 .Entity = New EntityMetadata With {
  .SchemaName = _customEntityName,
  .DisplayName = New Label("Bank Account", 1033),
  .DisplayCollectionName = New Label("Bank Accounts", 1033),
  .Description = New Label("An entity to store information about customer bank accounts", 1033),
  .OwnershipType = OwnershipTypes.UserOwned,
  .IsActivity = False},
 .PrimaryAttribute = New StringAttributeMetadata With {
  .SchemaName = "new_accountname",
  .RequiredLevel = New AttributeRequiredLevelManagedProperty(AttributeRequiredLevel.None),
  .MaxLength = 100,
  .Format = StringFormat.Text,
  .DisplayName = New Label("Account Name", 1033),
  .Description = New Label("The primary attribute for the Bank Account entity.", 1033)
 }
}
'Define the entity
' Define the primary attribute for the entity
_serviceProxy.Execute(createrequest)
Console.WriteLine("The bank account entity has been created.")

사용자 지정 엔터티에 문자열 특성 추가

다음 샘플은 StringAttributeMetadata 특성을 Bank Account 엔터티에 추가합니다.


CreateAttributeRequest createBankNameAttributeRequest = new CreateAttributeRequest
{
 EntityName = _customEntityName,
 Attribute = new StringAttributeMetadata
 {
  SchemaName = "new_bankname",
  RequiredLevel = new AttributeRequiredLevelManagedProperty(AttributeRequiredLevel.None),
  MaxLength = 100,
  FormatName = StringFormatName.Text,
  DisplayName = new Label("Bank Name", 1033),
  Description = new Label("The name of the bank.", 1033)
 }
};

_serviceProxy.Execute(createBankNameAttributeRequest);

Dim createBankNameAttributeRequest As CreateAttributeRequest = New CreateAttributeRequest With {
 .EntityName = _customEntityName,
 .Attribute = New StringAttributeMetadata With {
  .SchemaName = "new_bankname",
  .RequiredLevel = New AttributeRequiredLevelManagedProperty(AttributeRequiredLevel.None),
  .MaxLength = 100,
  .Format = StringFormat.Text,
  .DisplayName = New Label("Bank Name", 1033),
  .Description = New Label("The name of the bank.", 1033)
 }
}

_serviceProxy.Execute(createBankNameAttributeRequest)

사용자 지정 엔터티에 금액 특성 추가

다음 샘플은 MoneyAttributeMetadata 특성을 Bank Account 엔터티에 추가합니다.


CreateAttributeRequest createBalanceAttributeRequest = new CreateAttributeRequest
{
 EntityName = _customEntityName,
 Attribute = new MoneyAttributeMetadata
 {
  SchemaName = "new_balance",
  RequiredLevel = new AttributeRequiredLevelManagedProperty(AttributeRequiredLevel.None),
  PrecisionSource = 2,
  DisplayName = new Label("Balance", 1033),
  Description = new Label("Account Balance at the last known date", 1033),

 }
};

_serviceProxy.Execute(createBalanceAttributeRequest);

Dim createBalanceAttributeRequest As CreateAttributeRequest = New CreateAttributeRequest With {
 .EntityName = _customEntityName,
 .Attribute = New MoneyAttributeMetadata With {
  .SchemaName = "new_balance",
  .RequiredLevel = New AttributeRequiredLevelManagedProperty(AttributeRequiredLevel.None),
  .PrecisionSource = 2,
  .DisplayName = New Label("Balance", 1033),
  .Description = New Label("Account Balance at the last known date", 1033)
 }
}

_serviceProxy.Execute(createBalanceAttributeRequest)

사용자 지정 엔터티에 DateTime 특성 추가

다음 샘플은 DateTimeAttributeMetadata 특성을 Bank Account 엔터티에 추가합니다.


CreateAttributeRequest createCheckedDateRequest = new CreateAttributeRequest
{
 EntityName = _customEntityName,
 Attribute = new DateTimeAttributeMetadata
 {
  SchemaName = "new_checkeddate",
  RequiredLevel = new AttributeRequiredLevelManagedProperty(AttributeRequiredLevel.None),
  Format = DateTimeFormat.DateOnly,
  DisplayName = new Label("Date", 1033),
  Description = new Label("The date the account balance was last confirmed", 1033)

 }
};

_serviceProxy.Execute(createCheckedDateRequest);
Console.WriteLine("An date attribute has been added to the bank account entity.");

Dim createCheckedDateRequest As CreateAttributeRequest = New CreateAttributeRequest With {
 .EntityName = _customEntityName,
 .Attribute = New DateTimeAttributeMetadata With {
  .SchemaName = "new_checkeddate",
  .RequiredLevel = New AttributeRequiredLevelManagedProperty(AttributeRequiredLevel.None),
  .Format = DateTimeFormat.DateOnly,
  .DisplayName = New Label("Date", 1033),
  .Description = New Label("The date the account balance was last confirmed", 1033)
 }
}

_serviceProxy.Execute(createCheckedDateRequest)
Console.WriteLine("An date attribute has been added to the bank account entity.")

사용자 지정 엔터티에 조회 특성 추가

다음 샘플에서는 CreateOneToManyRequest를 사용하여 LookupAttributeMetadata 특성을 Bank Account 엔터티에 추가할 수 있도록 Contact 엔터티를 사용하여 일대다 관계를 만듭니다.

CreateOneToManyRequest req = new CreateOneToManyRequest()
{
    Lookup = new LookupAttributeMetadata()
    {
        Description = new Label("The referral (lead) from the bank account owner", 1033),
        DisplayName = new Label("Referral", 1033),
        LogicalName = "new_parent_leadid",
        SchemaName = "New_Parent_leadId",
        RequiredLevel = new AttributeRequiredLevelManagedProperty(AttributeRequiredLevel.Recommended)
    },
    OneToManyRelationship = new OneToManyRelationshipMetadata()
    {
        AssociatedMenuConfiguration = new AssociatedMenuConfiguration()
        {
            Behavior = AssociatedMenuBehavior.UseCollectionName,
            Group = AssociatedMenuGroup.Details,
            Label = new Label("Bank Accounts", 1033),
            Order = 10000
        },
        CascadeConfiguration = new CascadeConfiguration()
        {
            Assign = CascadeType.Cascade,
            Delete = CascadeType.Cascade,
            Merge = CascadeType.Cascade,
            Reparent = CascadeType.Cascade,
            Share = CascadeType.Cascade,
            Unshare = CascadeType.Cascade
        },
        ReferencedEntity = "lead",
        ReferencedAttribute = "leadid",
        ReferencingEntity = _customEntityName,
        SchemaName = "new_lead_new_bankaccount"
    }
};
_serviceProxy.Execute(req);

Dim req As New CreateOneToManyRequest() With {
 .Lookup = New LookupAttributeMetadata() With {
  .Description = New Label("The owner of the bank account", 1033),
  .DisplayName = New Label("Account Owner", 1033),
  .LogicalName = "new_parent_contactid",
  .SchemaName = "New_Parent_ContactId",
  .RequiredLevel = New AttributeRequiredLevelManagedProperty(AttributeRequiredLevel.ApplicationRequired)},
 .OneToManyRelationship = New OneToManyRelationshipMetadata() With {
  .AssociatedMenuConfiguration = New AssociatedMenuConfiguration() With {
   .Behavior = AssociatedMenuBehavior.UseCollectionName,
   .Group = AssociatedMenuGroup.Details,
   .Label = New Label("Bank Accounts", 1033),
   .Order = 10000},
  .CascadeConfiguration = New CascadeConfiguration() With {
   .Assign = CascadeType.Cascade,
   .Delete = CascadeType.Cascade,
   .Merge = CascadeType.Cascade,
   .Reparent = CascadeType.Cascade,
   .Share = CascadeType.Cascade,
   .Unshare = CascadeType.Cascade},
  .ReferencedEntity = Contact.EntityLogicalName,
  .ReferencedAttribute = "contactid",
  .ReferencingEntity = _customEntityName,
  .SchemaName = "new_contact_new_bankaccount"
 }
}
_serviceProxy.Execute(req)

참고 항목

CreateEntityRequest
샘플 및 도우미 코드 사용
Customize 엔터티 메타데이터
사용자 지정 가능한 엔터티는 무엇입니까?
엔터티 검색, 업데이트 및 삭제
전자 메일 가능한 엔터티 만들기 및 업데이트
사용자 지정 활동 엔터티 만들기
엔터티의 아이콘 수정
엔터티의 메시지 수정

Microsoft Dynamics 365

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