Dynamics CRM API

Overview

These public interfaces are used in Dynamics CRM components. They are provided for implementing advanced functionality in your scripts. In order for you to use these interfaces in your project, you have to reference CozyRoc.SSISPlus.dll and CozyRoc.Dynamics.dll libraries. Also include CozyRoc.Dynamics.Crm, CozyRoc.Dynamics.Crm.Service, CozyRoc.Dynamics.Crm.MetadataService, CozyRoc.Dynamics.Crm.DiscoveryService namespaces.

IConnection / ICrmConnection

When you call Dynamics CRM Connection Manager AcquireConnection method, it returns object implementing IConnection interface. This is the interface used for interaction with Dynamics CRM service.

Connect method

Connects to Dynamics CRM service.

Close method

Closes the connection to Dynamics CRM service. Use always after you finish working with the service.

IsConnected method

Returns true if connected to the service.

GetService method

Get specific Dynamics CRM web service. These are the method parameters:

  • service (int) – service type. It can be one of the options listed in the following table.

    Value Result Service
    0

    • CRM 2011 – returns service class from CozyRoc.Dynamics.Crm2011.OrganizationService namespace
    • CRM 4.0 – returns CrmService class from CozyRoc.Dynamics.Crm.Service namespace.
    • CRM 3.0 – returns service class from CozyRoc.Dynamics.Crm3.Service namespace.

    1

    • CRM 2011 – Not available.
    • CRM 4.0 – returns MetadataService class from CozyRoc.Dynamics.Crm.MetadataService namespace.
    • CRM 3.0 – returns service class from CozyRoc.Dynamics.Crm3.MetadataService namespace.

    2

    • CRM 2011 – returns service class from CozyRoc.Dynamics.Crm2011.DiscoveryService namespace.
    • CRM 4.0 – returns CrmDiscoveryService class from CozyRoc.Dynamics.Crm.DiscoveryService namespace.
    • CRM 3.0 – Not available.

GetOrganizations method (1.6)

Gets organizations list.

GetEntityList method

Gets entities list with specific privilege. These are the method parameters:

  • privilege (int) – entity privilege. It can be one of the options listed in the following table.

    Value Description
    0 Privilege unspecified. All entities will be returned.
    1 Return entities, which permit record creation.
    2 Return entities, which can be read.
    3 Return entities, which can be updated.
    4 Return entities, which permit record removal.

Fetch method

Query Dynamics CRM service. The method returns XML string with the result of the query. These are the method parameters:

  • fetchXML (string) FetchXML query statement.

GetEntityAttributes method

DEPRECATED: Use IEntity.GetAttributes method instead.

Get entity attributes. The method returns array of IAttribute objects. These are the method parameters:

  • entity (string) – entity name.

GetFetchAttributes method

Get attributes specified in query. The method returns array of IAttribute objects. These are the method parameters:

  • fetchXML (string)FetchXML query statement.

ConstructEntity method

DEPRECATED: Use GetEntity method instead.

Construct object, which will be used to manipulate entity. The method returns ICrmEntity object. These are the method parameters:

  • name (string) – entity name.

CreateEntityRecord method

DEPRECATED: Use IEntity interface instead.

Creates record in entity. The method returns string with identifier of the created record. These are the method parameters:

  • entity (ICrmEntity) – object with create data.
  • ignoreMissingId – specify to ignore attributes referencing missing data.
  • detectDuplicate – specify to enable duplicate detection rule.

UpdateEntityRecord method

DEPRECATED: Use IEntity interface instead.

Updates existing record in entity. These are the method parameters:

  • entity (ICrmEntity) – object with update data.
  • ignoreMissingId – specify to ignore attributes referencing missing data.
  • detectDuplicate – specify to enable duplicate detection rule.

DeleteEntityRecord method

DEPRECATED: Use IEntity interface instead.

Deletes record in entity. These are the method parameters:

  • entity (ICrmEntity) – object with delete data.

UpsertEntityRecord method (1.6)

DEPRECATED: Use IEntity interface instead.

Update and insert a record in destination entity. These are the method parameters:

  • entity (ICrmEntity) – object with update data.
  • ignoreMissingId – specify to ignore attributes referencing missing data.

GetEntity method (1.6 SR-1)

Get object used to manage Dynamics CRM entity. The method returns IEntity object. These are the method parameters:

  • name (string) – entity name.

DeploymentType property (int)

Specify deployment type. This property has the options listed in the following table.

Value Description
0 Connect to on-premise Dynamics CRM server.
1 Connect to Dynamics CRM Live service.
2 Connect to hosted Dynamics CRM.
3 Connect to Dynamics CRM 3.0 system.
4 Connect to Dynamics CRM 2011 web services (1.6).

ServerHost property (string)

Specify the name or IP address of the Dynamics CRM server.

ServerUser property (string)

Specify user name to access the Dynamics CRM service.

ServerPassword property (string)

Specify user password to access the Dynamics CRM service.

OrganizationName property (string)

Specify organization name. Note: Not available in CRM 3.0

ServerTimeout property (int)

Specify the number of seconds before timing out session connect. The default value of this property is 100 seconds.

RetainSameConnection property (bool)

Specify if all clients should use the same connection. This property has the options listed in the following table.

Value Description
True All clients use same connection (default).
False Every client uses different connection.

ProxyHost property (string)

Specify the name or IP address of the proxy server.

ProxyPort property (int)

Specify the port number on the proxy server to use for the connection.

ProxyUser property (string)

Specify user name to access the proxy server.

ProxyPassword property (string)

Specify password to access the proxy server.

IAttribute / ICrmAttribute

This interface is used to retrieve entity attributes information.

Name property (string)

Returns attribute name.

CanRead property (bool)

Returns true if attribute can be read.

CanCreate property (bool)

Returns true if attribute can be specified for record creation.

CanUpdate property (bool)

Returns true if attribute can be specified for record update.

CanUpdate property (bool)

Returns true if attribute is primary key.

AttributeType property (DataType)

Returns SSIS attribute type.

Reference property (string)

Returns attribute entity reference if attribute is lookup.

CrmAttribute property (object)

Returns internal AttributeMetadata object.

CrmType property (int) (1.6)

Returns attribute type. It can be one of the options listed in the following table.

CRM 3.0, CRM 4.0 CRM 2011

Value Description
0 Boolean
1 Customer
2 DateTime
3 Decimal
4 Float
5 Integer
6 Internal
7 Lookup
8 Memo
9 Money
10 Owner
11 PartyList
12 Picklist
13 PrimaryKey
14 State
15 Status
16 String
17 UniqueIdentifier
18 Virtual
19 CalendarRules

Value Description
0 Boolean
1 Customer
2 DateTime
3 Decimal
4 Double
5 Integer
6 Lookup
7 Memo
8 Money
9 Owner
10 PartyList
11 Picklist
12 State
13 Status
14 String
15 UniqueIdentifier
16 CalendarRules
17 Virtual
18 BigInt
19 ManagedProperty
20 EntityName

Length property (int) (1.6)

Returns attribute length.

Precision property (int) (1.6)

Returns attribute precision.

Scale property (int) (1.6)

Returns attribute scale.

ICrmEntity

DEPRECATED: Use IEntity interface instead.

This interface is used to manipulate entity record.

AddAttribute method

Adds attribute. The method returns the index of the newly inserted attribute. These are the method parameters:

  • name (string) – attribute name.
  • attributeType (int) – attribute type. For valid values check CrmType property in IAttribute interface.
  • reference (string) – entity reference. Only used when dealing with lookup attributes.

GetAttributesCount method

Return count of attributes.

SetAttributeValue method

Sets attribute value. These are the method parameters:

  • index (int) – attribute index.
  • value (object) – attribute value.

GetAttributeValue method

Returns attribute value. These are the method parameters:

  • index (int) – attribute index.

ConstructDynamicEntity method

Constructs DynamicEntity object.

Name property (string)

Returns the entity name this object is associated with.

IEntity / ICrmEntity2 (1.6 SR-1)

This interface is used to manipulate entity record.

GetAttributes method

Get entity attributes. The method returns array of IAttribute objects.

NewEntity method

Constructs new Dynamics CRM entity data instance.

SetAttributeValue method

Sets attribute value in entity instance. These are the method parameters:

  • entity (object) – entity instance.
  • name (string) – attribute name.
  • value (object) – attribute value.

GetAttributeValue method

Returns attribute value from entity instance. These are the method parameters:

  • entity (object) – entity instance.
  • name (string) – attribute name.

Create method

Creates records in entity. The method returns array of IStatus objects for each input object. These are the method parameters:

  • list (object array) – array of Dynamics CRM entities to create.
  • ignoreMissingId – specify to ignore attributes referencing missing data.
  • detectDuplicate – specify to enable duplicate detection rule.

Update method

Updates existing records in entity. The method returns array of IStatus objects for each input object. These are the method parameters:

  • list (object array) – array of Dynamics CRM entities with update data.
  • ignoreMissingId – specify to ignore attributes referencing missing data.
  • detectDuplicate – specify to enable duplicate detection rule.

Upsert method

Create records and update existing records in entity. The method returns array of IStatus objects for each input object. These are the method parameters:

  • list (object array) – array of Dynamics CRM entities with create and update data.
  • ignoreMissingId – specify to ignore attributes referencing missing data.

Delete method

Delete existing records in entity. The method returns array of IStatus objects for each input object. These are the method parameters:

  • list (object array) – array of Dynamics CRM entities to delete.

IStatus / ICrmStatus (1.6 SR-1)

This interface is used for reporting back status.

ID property (string)

Returns the Dynamics CRM entity identifier.

Code property (int)

Returns the Dynamics CRM error code. If zero, there is no error.

Message property (string)

Returns the Dynamics CRM status message.