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.Service, CozyRoc.Dynamics.Crm.MetadataService, CozyRoc.Dynamics.Crm.DiscoveryService namespaces.

ICrmConnection

When you call Dynamics CRM Connection Manager AcquireConnection method, it returns object implementing ICrmConnection 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:

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

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

  • entity (string) – entity name.

GetFetchAttributes method

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

  • fetchXML (string)FetchXML query statement.

ConstructEntity method

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

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.

UpdateEntityRecord method

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

  • entity (ICrmEntity) – object with update data.

DeleteEntityRecord method

Deletes record in entity. These are the method parameters:

  • entity (string) – entity name.
  • id (string) – identifier of record to delete.

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. Note: When this option is selected, GetService method will return classes defined in CozyRoc.Dynamics.Crm3.Service, CozyRoc.Dynamics.Crm3.MetadataService namespaces.

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.

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 (int)

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

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

Reference property (string)

Returns attribute entity reference if attribute is lookup.

RawAttribute property (object)

Returns internal AttributeMetadata object.

ICrmEntity

This interface is used to manipulate entity record.

AddProperty method

Add property. The method returns the index of the newly inserted property. These are the method parameters:

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

GetPropertiesCount method

Return count of properties.

SetPropertyValue method

Sets property value. These are the method parameters:

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

GetPropertyValue method

Returns property value. These are the method parameters:

  • index (int) – property index.

ConstructDynamicEntity method

Constructs DynamicEntity object.

Name property (string)

Returns the entity name this object is associated with.