Created
November 1, 2012 16:15
-
-
Save tswann/3994712 to your computer and use it in GitHub Desktop.
Example of creating a custom Dynamics CRM entity using the Xrm SDK.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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