CreateRequest Class
Contains the data that is needed to create a record. Namespace: Microsoft.Xrm.Sdk.Messages
Assembly: Microsoft.Xrm.Sdk (in Microsoft.Xrm.Sdk.dll)
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);
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 |
Both | |
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 |
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 |
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 |
Development Platforms
Windows Server 2008Target Platforms
Windows Server 2008, Windows 7 (All Versions), Windows Vista (All Versions)Send comments about this topic to Microsoft.
© 2011 Microsoft Corporation. All rights reserved.