This is the first blog in the series where we will play around with MetaData service in CRM 2011 and answer some of the questions for Adam. Today Adam wants to know how to create an entity using the SDK or metadata service. Here is how we can do that.
We will use the CreateEntityRequest Message with Execute method of Organization service to create the entity. CreateEntityRequest has a member “Entity” that takes in the new entity to be created.
CreateEntityRequest request = new CreateEntityRequest
{
Entity = new EntityMetadata
{
SchemaName = entity.SchemaName,
DisplayName = new Label(“Adam”, “1033”),
DisplayCollectionName = new Label(“Humans”, “1033”),
LogicalName = “new_Adam”
}
};
In the next blog we will add attributes to entities.
Small doubt, Will this entity appear in organization service or we need to publish the solution.?
You will have to publish this entity. You can publish it using SDK and then you will be able to access it via your service. Let me know if you need help with code to publish it.