0
votes

Is there way I can connect to CRM dynamics and create custom entity itself. In API, I will pass entity name, fields, datatype and etc details required for creating custom entity.

I would like to use C# for making API calls.

1

1 Answers

0
votes

Yes. You need to use the Metadata services.

Sample: Create and update entity metadata.

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,
        FormatName = StringFormatName.Text,
        DisplayName = new Label("Account Name", 1033),
        Description = new Label("The primary attribute for the Bank Account entity.", 1033)
    }

};
_serviceProxy.Execute(createrequest);