CrmService.Create Method

banner art

Creates an instance of an entity.

Syntax

[Visual Basic]
Public Function Create(
  ByVal entity As BusinessEntity
) As Guid

[C#]
public Guid Create(
  BusinessEntity  entity
);

[JScript]
public function Create(
  entity : BusinessEntity
) : Guid;

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 CRM entity that supports the Create message.

To perform this action, the caller must have the Create privilege for the entity type and access rights on the entity instance specified in the request class. 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. 
CrmService service = new CrmService();
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 CRM.
Guid contactGuid = service.Create(contact);

[Visual Basic .NET]
' Set up the CRM service.
Dim service As New CrmService()
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 CRM.
Dim contactGuid As Guid = service.Create(contact)

See Also

© 2007 Microsoft Corporation. All rights reserved.