CreateEntityRequest Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Contains the data that is needed to create a table, and optionally, to add it to a specified unmanaged solution.
public ref class CreateEntityRequest sealed : Microsoft::Xrm::Sdk::OrganizationRequest
[System.Runtime.Serialization.DataContract(Namespace="http://schemas.microsoft.com/xrm/2011/Contracts")]
public sealed class CreateEntityRequest : Microsoft.Xrm.Sdk.OrganizationRequest
[<System.Runtime.Serialization.DataContract(Namespace="http://schemas.microsoft.com/xrm/2011/Contracts")>]
type CreateEntityRequest = class
inherit OrganizationRequest
Public NotInheritable Class CreateEntityRequest
Inherits OrganizationRequest
- Inheritance
- Attributes
Examples
The following example shows how to use this message. For this sample to work correctly, you must be connected to the server to get an IOrganizationService interface instance.
/// <summary>
/// Demonstrates creating a table
/// </summary>
/// <param name="service">Authenticated IOrganizationService instance</param>
static void CreateTable(IOrganizationService service) {
string prefix = "sample";
int languagecode = 1033; //English
string tableSchemaName = $"{prefix}_BankAccount";
string primaryNameColumnName = $"{prefix}_AccountName";
string solutionUniqueName = "SolutionName";
CreateEntityRequest request = new()
{
//Define the table
Entity = new EntityMetadata
{
SchemaName = tableSchemaName,
DisplayName = new Label("Bank Account", languagecode),
DisplayCollectionName = new Label("Bank Accounts", languagecode),
Description = new Label("An table to store information about customer bank accounts", languagecode),
OwnershipType = OwnershipTypes.UserOwned,
IsActivity = false,
},
// Define the primary name column for the table
PrimaryAttribute = new StringAttributeMetadata
{
SchemaName = primaryNameColumnName,
RequiredLevel = new AttributeRequiredLevelManagedProperty(AttributeRequiredLevel.None),
MaxLength = 100,
FormatName = StringFormatName.Text,
DisplayName = new Label("Account Name", languagecode),
Description = new Label("The primary column for the Bank Account table.", languagecode)
},
SolutionUniqueName = solutionUniqueName
};
var response = (CreateEntityResponse)service.Execute(request);
Console.WriteLine($"Table ID:{response.EntityId}");
Console.WriteLine($"Primary name column ID:{response.AttributeId}");
}
Output:
Table ID:ab84f688-a56f-ee11-8df0-000d3a993550
Primary name column ID:ac84f688-a56f-ee11-8df0-000d3a993550
Sample code on GitHub
Create and update table definitions
Remarks
Usage
Pass an instance of this class to the Execute(OrganizationRequest) method, which returns an instance of the CreateEntityResponse class.
Privileges and Access Rights
To perform this action, the caller must have the following privileges that are assigned to the System Administrator and System Customizer roles:
prvCreateEntity
, prvCreateQuery
, prvCreateSdkMessage
, prvCreateSdkMessageProcessingStep
, prvCreateSystemForm
, prvReadCustomization
, prvReadPluginType
, prvReadQuery
, prvReadSdkMessage
, prvReadSystemForm
, prvWriteQuery
, prvWriteSystemForm
Constructors
CreateEntityRequest() |
Initializes a new instance of the CreateEntityRequest class. |
Properties
Entity |
Gets or sets the metadata for the table that you want to create. Required. |
ExtensionData |
Gets or sets the structure that contains extra data. Optional. (Inherited from OrganizationRequest) |
HasActivities |
Gets or sets whether the table is created that has a special relationship to activity entities a nd is a valid regarding object for the activity. Optional. |
HasFeedback |
Gets or sets whether the table will have a special relationship to the Feedback table. Optional. |
HasNotes |
Gets or sets whether the custom table that is created has a special relationship to the annotation table. Optional. |
Item[String] |
Gets or sets the indexer for the |
Parameters |
Gets or sets the collection of parameters for the request. Required, but is supplied by derived classes. (Inherited from OrganizationRequest) |
PrimaryAttribute |
Gets or sets the metadata for the primary name column for the new table. Required. |
RequestId |
Gets or sets the ID of the request. Optional. (Inherited from OrganizationRequest) |
RequestName |
Gets or sets the name of the request. Required, but is supplied by derived classes. (Inherited from OrganizationRequest) |
SolutionUniqueName |
Gets or sets the name of the unmanaged solution to which you want to add this table. Optional. |