Microsoft Dynamics Job Openings


Microsoft Dynamics Forums Homepage

Forum Home Forum Home > Microsoft Dynamics CRM > CRM - General
  New Posts New Posts RSS Feed - Custom Entity Record using SDK
  FAQ FAQ  Forum Search   Register Register  Login Login


Custom Entity Record using SDK

 Post Reply Post Reply
Author
Message
rsplajit View Drop Down
MicrosoftDynamicsForums.com Member
MicrosoftDynamicsForums.com Member


Joined: December 26 2011
Location: India
Status: Offline
Points: 15
Post Options Post Options   Thanks (0) Thanks(0)   Quote rsplajit Quote  Post ReplyReply Direct Link To This Post Topic: Custom Entity Record using SDK
    Posted: May 10 2012 at 2:32am
Hello Friends,

Can you please tell me, How to create a custom entity record using SDK?

Thanks

Back to Top
Sponsored Links


Back to Top
bailliejoanna View Drop Down
MicrosoftDynamicsForums.com Member
MicrosoftDynamicsForums.com Member


Joined: August 25 2013
Status: Offline
Points: 4
Post Options Post Options   Thanks (0) Thanks(0)   Quote bailliejoanna Quote  Post ReplyReply Direct Link To This Post Posted: August 25 2013 at 2:49am
using (_serviceProxy = new OrganizationServiceProxy(serverConfig.OrganizationUri,
       serverConfig.HomeRealmUri,
       serverConfig.Credentials,
       serverConfig.DeviceCredentials))
{
       _serviceProxy.ServiceConfiguration.CurrentServiceEndpoint.Behaviors.Add(new ProxyTypesBehavior());

       // Create custom entity.
       CreateEntityRequest _entity = new CreateEntityRequest()
       {
          Entity = new EntityMetadata
          {
             LogicalName = "new_payment",
             DisplayName = new Label("Payment", 1033),
             DisplayCollectionName = new Label("Payment", 1033),
             OwnershipType = OwnershipTypes.UserOwned,
             SchemaName = "New_Payment",
             IsActivity = false,
             IsAvailableOffline = true,
             IsAuditEnabled = new BooleanManagedProperty(true),
             IsMailMergeEnabled = new BooleanManagedProperty(false)
           },
           HasActivities = false,
           HasNotes = true,
           PrimaryAttribute = new StringAttributeMetadata()
           {
              SchemaName = "Description",
              LogicalName = "description",
              RequiredLevel = new AttributeRequiredLevelManagedProperty(AttributeRequiredLevel.None),
              MaxLength = 100,
              DisplayName = new Label("Description", 1033)
           }
       };
       _serviceProxy.Execute(_entity);


       // Create custom attributes.
       CreateAttributeRequest attrReq = new CreateAttributeRequest()
       {
           Attribute = new StringAttributeMetadata()
           {
              LogicalName = "new_identity",
              DisplayName = new Label("Identity", 1033),
              SchemaName = "New_Identity",
              MaxLength = 500,
              RequiredLevel = new AttributeRequiredLevelManagedProperty(AttributeRequiredLevel.Recommended),
              IsSecured = true
            },
            EntityName = "new_payment"
       };
       CreateAttributeResponse identityAttributeResponse = (CreateAttributeResponse)_serviceProxy.Execute(attrReq);
       Guid _identityId = identityAttributeResponse.AttributeId;

       attrReq = new CreateAttributeRequest()
       {
          Attribute = new StringAttributeMetadata()
          {
             LogicalName = "new_message",
             DisplayName = new Label("Message", 1033),
             SchemaName = "New_Message",
             MaxLength = 140,
             RequiredLevel = new AttributeRequiredLevelManagedProperty(AttributeRequiredLevel.Recommended),
             IsSecured = true
           },
           EntityName = "new_payment"
       };

       // Execute the request.
       CreateAttributeResponse messageAttributeResponse = (CreateAttributeResponse)_serviceProxy.Execute(attrReq);
       Guid _messageId = messageAttributeResponse.AttributeId;

}

Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down


Copyright 2013 microsoftdynamicsforums.com. All rights reserved. MicrosoftDynamicsForums.com is an independent non-Microsoft website.
Email: contact AT microsoftdynamicsforums DOT com