CreateRequest Class

Applies To: Microsoft Dynamics CRM 2013, Microsoft Dynamics CRM Online

Contains the data that is needed to create a record.

Namespace: Microsoft.Xrm.Sdk.Messages
Assembly: Microsoft.Xrm.Sdk (in Microsoft.Xrm.Sdk.dll)

Syntax

'Declaration
<DataContractAttribute(Namespace:="https://schemas.microsoft.com/xrm/2011/Contracts")> _
Public NotInheritable Class CreateRequest
    Inherits OrganizationRequest
[DataContractAttribute(Namespace="https://schemas.microsoft.com/xrm/2011/Contracts")] 
public sealed class CreateRequest : OrganizationRequest

Example

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. For the complete sample, see the link later in this topic.

//Set the Web Resource properties
WebResource wr = new WebResource
{
    Content = getEncodedFileContents(@"../../" + webResource.path),
    DisplayName = webResource.displayName,
    Description = webResource.description,
    Name = _customizationPrefix + webResource.name,
    LogicalName = WebResource.EntityLogicalName,
    WebResourceType = new OptionSetValue(Int32.Parse(webResource.type))
};

// Using CreateRequest because we want to add an optional parameter
CreateRequest cr = new CreateRequest
{
    Target = wr
};
//Set the SolutionUniqueName optional parameter so the Web Resources will be
// created in the context of a specific solution.
cr.Parameters.Add("SolutionUniqueName", _ImportWebResourcesSolutionUniqueName);

CreateResponse cresp = (CreateResponse)_serviceProxy.Execute(cr);
'Set the Web Resource properties
Dim wr As WebResource =
    New WebResource With
    {
        .Content = getEncodedFileContents("../../" _
                                          & awebResource.path),
        .DisplayName = awebResource.displayName,
        .Description = awebResource.description,
        .Name = _customizationPrefix & awebResource.name,
        .LogicalName = WebResource.EntityLogicalName,
        .WebResourceType =
        New OptionSetValue(Int32.Parse(awebResource.type))
    }

' Using CreateRequest because we want to add an optional parameter
Dim cr As CreateRequest = New CreateRequest With {.Target = wr}
'Set the SolutionUniqueName optional parameter so the Web Resources will be
' created in the context of a specific solution.
cr.Parameters.Add("SolutionUniqueName",
                  _ImportWebResourcesSolutionUniqueName)

Dim cresp As CreateResponse = CType(_serviceProxy.Execute(cr), 
    CreateResponse)

Remarks

Message Availability

Not all entity types support this message offline. For some supported entities, this message works regardless whether the caller is connected to the server or offline. For other entities, the caller must be connected to the server before the message works. For more information, see Supported Entities later in this topic.

Usage

Pass an instance of this class to the Execute method, which returns an instance of the CreateResponse class.

This message supports one or more optional parameters. For more information, see Pass Optional Parameters in Messages.

Privileges and Access Rights

To perform this action, the caller must have privileges on the specified entity in the entity parameter. For a list of the required privileges, see Create Privileges.

Notes for Callers

This message creates a record with related records in one transaction. For a less complex method that creates a single record, use the Create method.

By default, the caller becomes the owner for the new record. For this message to work, the caller must have both Create and Read privileges for the entity. For more information, see Privileges by Entity. Or you can set the ownerid attribute for the record to the ID of another user.

Supported Entities

You can use this method to create any record of an entity (includes custom entities) that supports the CreateRequest message.

The following table shows the default entities that support this message. For the listed entities of this message, the Availability column shows Server if the caller must be connected to the server and shows Both if the caller can be either connected to, or disconnected from, the server.

Entity Availability

account

Both

activitymimeattachment

Both

annotation

Both

annualfiscalcalendar

Both

appointment

Both

asyncoperation

Server

attributemap

Server

businessunit

Server

businessunitnewsarticle

Both

calendar

Both

campaign

Both

campaignactivity

Both

campaignresponse

Both

columnmapping

Both

competitor

Both

connection

Both

connectionrole

Both

connectionroleobjecttypecode

Both

constraintbasedgroup

Both

contact

Both

contract

Both

contractdetail

Both

contracttemplate

Server

customeraddress

Both

customeropportunityrole

Both

customerrelationship

Both

discount

Server

discounttype

Server

duplicaterule

Server

duplicaterulecondition

Server

email

Both

emailserverprofile

Server

equipment

Server

fax

Both

fieldpermission

Server

fieldsecurityprofile

Server

fixedmonthlyfiscalcalendar

Both

goal

Server

goalrollupquery

Server

import

Both

importentitymapping

Both

importfile

Both

importjob

Both

importmap

Both

incident

Both

incidentresolution

Both

invoice

Both

invoicedetail

Both

isvconfig

Server

kbarticle

Both

kbarticlecomment

Both

kbarticletemplate

Both

lead

Both

letter

Both

list

Both

lookupmapping

Both

mailbox

Server

mailmergetemplate

Both

metric

Server

monthlyfiscalcalendar

Both

msdyn_postalbum

Server

msdyn_postconfig

Server

msdyn_postruleconfig

Server

opportunity

Both

opportunityclose

Both

opportunityproduct

Both

orderclose

Both

organizationui

Server

ownermapping

Both

phonecall

Both

picklistmapping

Both

pluginassembly

Server

plugintype

Server

post

Server

postcomment

Server

postfollow

Server

postlike

Server

pricelevel

Server

principalobjectattributeaccess

Server

processsession

Both

product

Server

productpricelevel

Server

publisher

Server

publisheraddress

Server

quarterlyfiscalcalendar

Both

queue

Server

queueitem

Both

quote

Both

quoteclose

Both

quotedetail

Both

recurrencerule

Server

recurringappointmentmaster

Both

relationshiprole

Both

relationshiprolemap

Both

report

Server

reportcategory

Server

reportentity

Server

reportvisibility

Server

resourcespec

Both

role

Server

rollupfield

Server

salesliterature

Server

salesliteratureitem

Server

salesorder

Both

salesorderdetail

Both

savedquery

Server

savedqueryvisualization

Server

sdkmessageprocessingstep

Server

sdkmessageprocessingstepimage

Server

sdkmessageprocessingstepsecureconfig

Server

semiannualfiscalcalendar

Both

service

Server

serviceappointment

Both

serviceendpoint

Server

sharepointdocumentlocation

Server

sharepointsite

Server

site

Server

solution

Server

subject

Both

systemform

Server

systemuser

Server

task

Both

team

Server

template

Both

territory

Server

tracelog

Both

transactioncurrency

Server

transformationmapping

Both

transformationparametermapping

Both

uom

Server

uomschedule

Both

userentityinstancedata

Both

userentityuisettings

Both

userform

Server

userquery

Both

userqueryvisualization

Both

webresource

Server

workflow

Server

workflowdependency

Server

workflowlog

Server

Inheritance Hierarchy

System.Object
   Microsoft.Xrm.Sdk.OrganizationRequest
    Microsoft.Xrm.Sdk.Messages.CreateRequest

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Platforms

Development Platforms

Windows Server 2008, Windows Server 2012, Windows 7 (All Versions), Windows 8 (All Versions)

Target Platforms

Windows Server 2008, ,Windows Server 2012, ,Windows 7 (All Versions),

Change History

See Also

Reference

CreateRequest Members
Microsoft.Xrm.Sdk.Messages Namespace
CreateResponse
IOrganizationService.Create Method
Create a New Entity Record Using the Early-bound Entity Classes and the Organization Service Context

Other Resources

Sample: Importing Files as Web Resources
Privileges by Entity

Send comments about this topic to Microsoft.
© 2013 Microsoft Corporation. All rights reserved.