Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

CrmService.Create Method

banner art

[Applies to: Microsoft Dynamics CRM 4.0]

Find the latest SDK documentation: CRM 2015 SDK

Creates an instance of an entity.

Syntax

[Visual Basic .NET]
Public Function Create(
  ByVal entity As BusinessEntity
) As Guid
[C#]
public Guid Create(
  BusinessEntity  entity
);

Parameters

entity

Specifies an instance of a class derived from BusinessEntity of the type of entity to create.

Return Value

Returns a Guid type that contains the ID of the newly created entity.

Remarks

Use this method to create an instance of any Microsoft Dynamics CRM entity that supports the Create message.

For better performance, use this method instead of using the Execute method with the Create message.

To perform this action, the caller must have access rights on the entity instance specified in the request class. For a list of required privileges, see Create Privileges.

The owner of the newly created instance should also have the Read privilege for the entity type.

Example

The following example demonstrates the use of the Create method.

// Set up the CRM Service.
CrmAuthenticationToken token = new CrmAuthenticationToken();
// You can use enums.cs from the SDK\Helpers folder to get the enumeration for Active Directory authentication.
token.AuthenticationType = 0; 
token.OrganizationName = "AdventureWorksCycle";
 
CrmService service = new CrmService();
service.Url = "http://<servername>:<port>/mscrmservices/2007/crmservice.asmx";
service.CrmAuthenticationTokenValue = token;
service.Credentials = System.Net.CredentialCache.DefaultCredentials;

// Create the contact object.
contact contact = new contact();

// Create the properties for the contact object.
contact.firstname = "Jesper";
contact.lastname = "Aaberg";
contact.address1_line1 = "23 Market St.";
contact.address1_city = "Sammamish";
contact.address1_stateorprovince = "MT";
contact.address1_postalcode = "99999";
contact.donotbulkemail = new CrmBoolean();
contact.donotbulkemail.Value = true;

// Create the contact in Microsoft Dynamics CRM.
Guid contactGuid = service.Create(contact);
[Visual Basic .NET]
' Set up the CRM Service.
Dim token As New CrmAuthenticationToken()
' You can use enums.cs from the SDK\Helpers folder to get the enumeration for Active Directory Authentication.
token.AuthenticationType = 0
token.OrganizationName = "AdventureWorksCycle";
 
Dim service As New CrmService()
service.Url = "http://<servername>:<port>/mscrmservices/2007/crmservice.asmx";
service.CrmAuthenticationTokenValue = token
service.Credentials = System.Net.CredentialCache.DefaultCredentials

' Create the contact object.
Dim contact As New contact()

' Create the properties for the contact object.
contact.firstname = "Jesper"
contact.lastname = "Aaberg"
contact.address1_line1 = "23 Market St."
contact.address1_city = "Sammamish"
contact.address1_stateorprovince = "MT"
contact.address1_postalcode = "99999"
contact.donotbulkemail = New CrmBoolean()
contact.donotbulkemail.Value = True

' Create the contact in Microsoft Dynamics CRM.
Dim contactGuid As Guid = service.Create(contact)

Requirements

Namespace: CrmService

See Also

Concepts

Tasks

Reference


© 2010 Microsoft Corporation. All rights reserved.


Show:
© 2015 Microsoft