Skip to content

Instantly share code, notes, and snippets.

@tswann
Created November 1, 2012 16:15
Show Gist options
  • Save tswann/3994712 to your computer and use it in GitHub Desktop.
Save tswann/3994712 to your computer and use it in GitHub Desktop.
Example of creating a custom Dynamics CRM entity using the Xrm SDK.
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,
Format = StringFormat.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.");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment