다음을 통해 공유


사용자 지정 활동 엔터티 만들기

 

게시 날짜: 2017년 1월

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

이 항목에는 사용자 지정 활동 엔터티를 만드는 방법을 보여 주는 샘플이 있습니다.

다음 샘플에서는 사용자 지정 엔터티를 만들고 IsActivity 속성을 true로 설정합니다. 모든 활동에서 사용되는 일반적인 ActivityPointer.Subject 특성에 부합하도록 모든 활동에는 서브젝트로 설정된 PrimaryAttributeSchemaName 이 있어야 합니다.


 // The custom prefix would typically be passed in as an argument or 
 // determined by the publisher of the custom solution.
 String prefix = "new_";

 String customEntityName = prefix + "instantmessage";

 // Create the custom activity entity.
 CreateEntityRequest request = new CreateEntityRequest
 {
     HasNotes = true,
     HasActivities = false,
     PrimaryAttribute = new StringAttributeMetadata
     {
         SchemaName = "Subject",
         RequiredLevel = new AttributeRequiredLevelManagedProperty(AttributeRequiredLevel.None),
         MaxLength = 100,
         DisplayName = new Label("Subject", 1033)
     },
     Entity = new EntityMetadata
     {
         IsActivity = true,
         SchemaName = customEntityName,
         DisplayName = new Label("Instant Message", 1033),
         DisplayCollectionName = new Label("Instant Messages", 1033),
         OwnershipType = OwnershipTypes.UserOwned,
         IsAvailableOffline = true,

     }
 };

 _serviceProxy.Execute(request);

 //Entity must be published

 // Add few attributes to the custom activity entity.
 CreateAttributeRequest fontFamilyAttributeRequest =
     new CreateAttributeRequest
{
    EntityName = customEntityName,
    Attribute = new StringAttributeMetadata
    {
        SchemaName = prefix + "fontfamily",
        DisplayName = new Label("Font Family", 1033),
        MaxLength = 100
    }
};
 CreateAttributeResponse fontFamilyAttributeResponse =
     (CreateAttributeResponse)_serviceProxy.Execute(
     fontFamilyAttributeRequest);

 CreateAttributeRequest fontColorAttributeRequest =
     new CreateAttributeRequest
 {
     EntityName = customEntityName,
     Attribute = new StringAttributeMetadata
     {
         SchemaName = prefix + "fontcolor",
         DisplayName = new Label("Font Color", 1033),
         MaxLength = 50
     }
 };
 CreateAttributeResponse fontColorAttributeResponse =
     (CreateAttributeResponse)_serviceProxy.Execute(
     fontColorAttributeRequest);

 CreateAttributeRequest fontSizeAttributeRequest =
     new CreateAttributeRequest
 {
     EntityName = customEntityName,
     Attribute = new IntegerAttributeMetadata
     {
         SchemaName = prefix + "fontSize",
         DisplayName = new Label("Font Size", 1033)
     }
 };
 CreateAttributeResponse fontSizeAttributeResponse =
     (CreateAttributeResponse)_serviceProxy.Execute(
     fontSizeAttributeRequest);

' The custom prefix would typically be passed in as an argument or 
' determined by the publisher of the custom solution.
Dim prefix As String = "new_"

Dim customEntityName As String = prefix & "instantmessage"

' Create the custom activity entity.
Dim request As CreateEntityRequest = New CreateEntityRequest With {
 .HasNotes = True,
 .HasActivities = False,
 .PrimaryAttribute = New StringAttributeMetadata With {
  .SchemaName = "Subject",
  .RequiredLevel = New AttributeRequiredLevelManagedProperty(AttributeRequiredLevel.None),
  .MaxLength = 100,
  .DisplayName = New Label("Subject", 1033)},
 .Entity = New EntityMetadata With {
  .IsActivity = True,
  .SchemaName = customEntityName,
  .DisplayName = New Label("Instant Message", 1033),
  .DisplayCollectionName = New Label("Instant Messages", 1033),
  .OwnershipType = OwnershipTypes.UserOwned,
  .IsAvailableOffline = True}}

_serviceProxy.Execute(request)

'Entity must be published

' Add few attributes to the custom activity entity.
Dim fontFamilyAttributeRequest As CreateAttributeRequest = New CreateAttributeRequest With {
 .EntityName = customEntityName,
 .Attribute = New StringAttributeMetadata With {
  .SchemaName = prefix & "fontfamily",
  .DisplayName = New Label("Font Family", 1033),
  .MaxLength = 100}}
Dim fontFamilyAttributeResponse As CreateAttributeResponse = CType(_serviceProxy.Execute(fontFamilyAttributeRequest), CreateAttributeResponse)

Dim fontColorAttributeRequest As CreateAttributeRequest = New CreateAttributeRequest With {
 .EntityName = customEntityName,
 .Attribute = New StringAttributeMetadata With {
  .SchemaName = prefix & "fontcolor",
  .DisplayName = New Label("Font Color", 1033),
  .MaxLength = 50}}
Dim fontColorAttributeResponse As CreateAttributeResponse = CType(_serviceProxy.Execute(fontColorAttributeRequest), CreateAttributeResponse)

Dim fontSizeAttributeRequest As CreateAttributeRequest = New CreateAttributeRequest With {
 .EntityName = customEntityName,
 .Attribute = New IntegerAttributeMetadata With {
  .SchemaName = prefix & "fontSize",
  .DisplayName = New Label("Font Size", 1033)}}
Dim fontSizeAttributeResponse As CreateAttributeResponse = CType(_serviceProxy.Execute(fontSizeAttributeRequest), CreateAttributeResponse)

참고 항목

CreateEntityRequest
샘플 및 도우미 코드 사용
사용자 지정 활동
Customize 엔터티 메타데이터
엔터티의 아이콘 수정
엔터티의 메시지 수정
샘플: 사용자 지정 활동 엔터티 만들기

Microsoft Dynamics 365

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