CSharp API: Difference between revisions

From RangerMSP Wiki - PSA software for MSPs and IT services providers
Jump to navigation Jump to search
Line 331: Line 331:
|-
|-
! '''Access modifier'''
! '''Access modifier'''
! '''Return value'''
! '''Property'''
! '''Property'''
! '''API Field Name'''
! '''API Field Name'''
! '''Return value'''
! '''Field length'''
! '''Field length'''
|-
|-
| public
| public
| string
| '''AccountREC_ID'''
| '''AccountREC_ID'''
| FLDCRDRECID
| FLDCRDRECID
| string
| 20
| 20
|-
|-
| public
| public
| string
| '''AccountManager'''
| '''AccountManager'''
| FLDCRDASSIGNCARDID
| FLDCRDASSIGNCARDID
| string
| 20
| 20
|-
|-
| public
| public
| string
| '''CompanyName'''
| '''CompanyName'''
| FLDCRDCOMPANY
| FLDCRDCOMPANY
| string
| 60
| 60
|-
|-
| public
| public
| string
| '''Contact'''
| '''Contact'''
| FLDCRDCONTACT
| FLDCRDCONTACT
| string
| 40
| 40
|-
|-
| public
| public
| string
| '''Assistant'''
| '''Assistant'''
| FLDCRDASSISTANT
| FLDCRDASSISTANT
| string
| 20
| 20
|-
|-
| public
| public
| string
| '''ContractREC_ID'''
| '''ContractREC_ID'''
| FLDCRDBCRECID
| FLDCRDBCRECID
| string
| 20
| 20
|-
|-
| public
| public
| string
| '''AccountNumber'''
| '''AccountNumber'''
| FLDCRDCARDID2
| FLDCRDCARDID2
| string
| 15
| 15
|-
|-
| public
| public
| string
| '''ID'''
| '''ID'''
| FLDCRDCARDID3
| FLDCRDCARDID3
| string
| 15
| 15
|-
|-
| public
| public
| string
| '''PopupMessage'''
| '''PopupMessage'''
| FLDCRDCARDMESSAGE
| FLDCRDCARDMESSAGE
| string
| Unlimited
| Unlimited
|-
|-
| public
| public
| string
| '''AddressLine1'''
| '''AddressLine1'''
| FLDCRDADDRESS1
| FLDCRDADDRESS1
| string
| 40
| 40
|-
|-
| public
| public
| string
| '''AddressLine2'''
| '''AddressLine2'''
| FLDCRDADDRESS2
| FLDCRDADDRESS2
| string
| 40
| 40
|-
|-
| public
| public
| string
| '''AddressLine3'''
| '''AddressLine3'''
| FLDCRDADDRESS3
| FLDCRDADDRESS3
| string
| 40
| 40
|-
|-
| public
| public
| string
| '''City'''
| '''City'''
| FLDCRDCITY
| FLDCRDCITY
| string
| 30
| 30
|-
|-
| public
| public
| string
| '''Country'''
| '''Country'''
| FLDCRDSTATE
| FLDCRDSTATE
| string
| 20
| 20
|-
|-
| public
| public
| string
| '''State'''
| '''State'''
| FLDCRDCOUNTRY
| FLDCRDCOUNTRY
| string
| 30
| 30
|-
|-
| public
| public
| string
| '''Zip'''
| '''Zip'''
| FLDCRDZIP
| FLDCRDZIP
| string
| 15
| 15
|-
|-
| public
| public
| DateTime
| '''CreationDate'''
| '''CreationDate'''
| FLDCRDCREATEDATE
| FLDCRDCREATEDATE
| DateTime
| N/A
| N/A
|-
|-
| public
| public
| string
| '''CreatedByUser'''
| '''CreatedByUser'''
| FLDCRDCREATEUSERID
| FLDCRDCREATEUSERID
| string
| 20
| 20
|-
|-
| public
| public
| string
| '''Dear'''
| '''Dear'''
| FLDCRDDEAR
| FLDCRDDEAR
| string
| 20
| 20
|-
|-
| public
| public
| string
| '''Department'''
| '''Department'''
| FLDCRDDEPARTMENT
| FLDCRDDEPARTMENT
| string
| 35
| 35
|-
|-
| public
| public
| string
| '''DocumentsStoreDirectory'''
| '''DocumentsStoreDirectory'''
| FLDCRDDOCSFOLDER
| FLDCRDDOCSFOLDER
| string
| 100
| 100
|-
|-
| public
| public
| string
| '''EmailAddress1'''
| '''EmailAddress1'''
| FLDCRDEMAIL1
| FLDCRDEMAIL1
| string
| 70
| 70
|-
|-
| public
| public
| string
| '''EmailAddress2'''
| '''EmailAddress2'''
| FLDCRDEMAIL2
| FLDCRDEMAIL2
| string
| 70
| 70
|-
|-
| public
| public
| int
| '''AccountType'''
| '''AccountType'''
| FLDCRDENTITYKIND
| FLDCRDENTITYKIND
| int
| N/A
| N/A
|-
|-
Line 493: Line 493:
|-
|-
| public
| public
| string
| '''FileAs'''
| '''FileAs'''
| FLDCRDFULLNAME
| FLDCRDFULLNAME
| string
| 60
| 60
|-
|-
| public
| public
| string
| '''Type'''
| '''Type'''
| FLDCRDKIND
| FLDCRDKIND
| string
| 30
| 30
|-
|-
Line 523: Line 523:
|-
|-
| public
| public
| string
| '''Phone1Ext'''
| '''Phone1Ext'''
| FLDCRDPHNDESC1
| FLDCRDPHNDESC1
| string
| 40
| 40
|-
|-
| public
| public
| string
| '''Phone2Ext'''
| '''Phone2Ext'''
| FLDCRDPHNDESC2
| FLDCRDPHNDESC2
| string
| 40
| 40
|-
|-
| public
| public
| string
| '''Phone3Ext'''
| '''Phone3Ext'''
| FLDCRDPHNDESC3
| FLDCRDPHNDESC3
| string
| 15
| 15
|-
|-
| public
| public
| string
| '''Phone4Ext'''
| '''Phone4Ext'''
| FLDCRDPHNDESC4
| FLDCRDPHNDESC4
| string
| 15
| 15
|-
|-
| public
| public
| string
| '''Phone1'''
| '''Phone1'''
| FLDCRDPHONE1
| FLDCRDPHONE1
| string
| 25
| 25
|-
|-
| public
| public
| string
| '''Phone2'''
| '''Phone2'''
| FLDCRDPHONE2
| FLDCRDPHONE2
| string
| 25
| 25
|-
|-
| public
| public
| string
| '''Phone3'''
| '''Phone3'''
| FLDCRDPHONE3
| FLDCRDPHONE3
| string
| 25
| 25
|-
|-
| public
| public
| string
| '''Phone4'''
| '''Phone4'''
| FLDCRDPHONE4
| FLDCRDPHONE4
| string
| 25
| 25
|-
|-
| public
| public
| string
| '''Region'''
| '''Region'''
| FLDCRDREGIONCODE
| FLDCRDREGIONCODE
| string
| 15
| 15
|-
|-
| public
| public
| string
| '''PopupMessageDisplayIndication'''
| '''PopupMessageDisplayIndication'''
| FLDCRDSHOWMESSAGE
| FLDCRDSHOWMESSAGE
| string
| 1
| 1
|-
|-
| public
| public
| string
| '''SubContractCode'''
| '''SubContractCode'''
| FLDCRDSUBCODE
| FLDCRDSUBCODE
| string
| 15
| 15
|-
|-
| public
| public
| string
| '''Salutation'''
| '''Salutation'''
| FLDCRDSUFFIX
| FLDCRDSUFFIX
| string
| 20
| 20
|-
|-
| public
| public
| string
| '''Tax1'''
| '''Tax1'''
| FLDCRDTAXCODE1
| FLDCRDTAXCODE1
| string
| 3
| 3
|-
|-
| public
| public
| string
| '''Tax2'''
| '''Tax2'''
| FLDCRDTAXCODE2
| FLDCRDTAXCODE2
| string
| 3
| 3
|-
|-
| public
| public
| string
| '''Title'''
| '''Title'''
| FLDCRDTITLE
| FLDCRDTITLE
| string
| 30
| 30
|-
|-
| public
| public
| string
| '''LastUpdatedBy'''
| '''LastUpdatedBy'''
| FLDCRDUPDATEUSERID
| FLDCRDUPDATEUSERID
| string
| 20
| 20
|-
|-
| public
| public
| string
| '''WebAddress1'''
| '''WebAddress1'''
| FLDCRDURL1
| FLDCRDURL1
| string
| 100
| 100
|-
|-
| public
| public
| string
| '''WebAddress2'''
| '''WebAddress2'''
| FLDCRDURL2
| FLDCRDURL2
| string
| 100
| 100
|-
|-
| public
| public
| string
| '''Status'''
| '''Status'''
| FLDCRDUSER1
| FLDCRDUSER1
| string
| 30
| 30
|-
|-
| public
| public
| string
| '''Field1'''
| '''Field1'''
| FLDCRDUSER2
| FLDCRDUSER2
| string
| 30
| 30
|-
|-
| public
| public
| string
| '''Field2'''
| '''Field2'''
| FLDCRDUSER3
| FLDCRDUSER3
| string
| 30
| 30
|-
|-
| public
| public
| string
| '''Field3'''
| '''Field3'''
| FLDCRDUSER4
| FLDCRDUSER4
| string
| 30
| 30
|-
|-
| public
| public
| string
| '''Field4'''
| '''Field4'''
| FLDCRDUSER5
| FLDCRDUSER5
| string
| 30
| 30
|}
|}

Revision as of 19:28, 18 March 2011

Disclaimer

This documentation refers to CommitCRM 5.6 or later version and assumes CommitCRM is installed and accessible on the local computer.

Introduction

This document demonstrates how to use the CommitCRM C# API library in order to programmatically connect to your CommitCRM server and query or manipulate the CommitCRM database.


System Requirements

  • CommitCRM 5.6 or later.
  • Visual C# .NET 2008 or Visual C# .NET 2010.
  • CommitLib.dll (the CommitCRM C# compiled library).

Getting Started

After you create your C# project, you'll need to add a reference to the CommitLib.dll file, in order to have access to the CommitCRM library classes.

Each application using the library will have to initialize on startup the CommitCRM.Application object and terminate it on exit. Initialization method requires that you pass an object instance of CommitCRM.Config class configured with the following settings:

  • AppName
This is free text, preferably the name of your application.
  • CommitDllFolder
Behind the scenes the library uses the two CommitCRM API dlls: CmtDbEng.dll and CmtDbQry.dll.
In the default CommitCRM installation you'll find these files in 'C:\\Commit\\ThirdParty\\UserDev'.
Important Note: Always point to this folder and do not copy the dll files elsewhere. This is because when the CommitCRM version upgrade runs it also upgrades the dll files stored in this folder. This verifies that you will always be using the latest release.
  • CommitDbFolder
Path to the CommitCRM database, default is 'C:\\Commit\\db'.

Assuming these default values, we can configure the CommitCRM.Config object like this:

CommitCRM.Config config = new CommitCRM.Config();
config.AppName = "C# Demo";
config.CommitDllFolder = "C:\\Commit\\ThirdParty\\UserDev";
config.CommitDbFolder = "C:\\Commit\\db";

You should of course check where these paths are exactly on your disk and modify these values accordingly.

Now we can initialize the CommitCRM.Application object with these settings:

CommitCRM.Application.Initialize(config);

If anything goes wrong, the above line will throw an exception of the CommitCRM.Exception class. To prevent unexpected termination of the program execution, we recommend having any call to the CommitCRM library enclosed in a try/catch block.

Before exit, we terminate the CommitCRM.Application object:

CommitCRM.Application.Terminate();

The most basic C# application that just connects to CommitCRM and terminates could look something like this:

try
{
    CommitCRM.Config config = new CommitCRM.Config();
    config.AppName = "C# Demo";
    config.CommitDllFolder = "C:\\Commit\\ThirdParty\\UserDev";
    config.CommitDbFolder = "C:\\Commit\\db";

    CommitCRM.Application.Initialize(config);

    //At this point we have successfully initialized the CommitCRM.Application
    //and can start using the other library classes
}
catch (CommitCRM.Exception exc)
{
    Console.Out.Write(exc.Message);
}
finally
{
    CommitCRM.Application.Terminate();
}

Now that we have confirmed the connectivity to the CommitCRM server (if the above code successfully runs), we can continue adding more functionality to the example.

The library exposes as C# classes the same CommitCRM objects (Account, Ticket etc.) available through the native CommitCRM API and you can refer to the API Reference Manual for database fields reference.


With any of these objects you can:

  • Search and query for objects with CommitCRM.ObjectQuery that satisfy certain criteria.
  • Read and display the properties of the retrieved objects.
  • Update and save the properties of the retrieved objects.
  • Create and save new objects.


Now let's see how we can search for CommitCRM.Account objects. We instantiate an object of the CommitCRM.ObjectQuery class and pass CommitCRM.Account class as generics parameter.

CommitCRM.ObjectQuery<CommitCRM.Account> accountSearch = new CommitCRM.ObjectQuery<CommitCRM.Account>();

CommitCRM.ObjectQuery class can accept any of the CommitCRM objects in this parameter, but we want to search for accounts now.

Next, we need to set criteria (or more than one) we want to search for:

accountSearch.AddCriteria(CommitCRM.Account.Fields.City, CommitCRM.OperatorEnum.opEqual, "New York");

he first parameter to the AddCriteria method is either a static object instance of CommitCRM.CmtField class representing the field we want to look in or the internal API field name. Refer to the API Field Name column in the Account Class table for a complete list of the available fields for the CommitCRM.Account class.

The second parameter is a compare operator. We here use the CommitCRM.OperatorEnum.opEqual to get only exact matches. In order to get a broader match in the results you can use CommitCRM.OperatorEnum.opLike operator.

The third parameter is the value we want to find. Prepending and/or appending % (percent) sign at the beginning and/or at the end while using CommitCRM.OperatorEnum.opLike operator, will match the phrase even if in the middle of a sentence.

Now we can execute the search and retrieve the CommitCRM.Account objects (if any):

List<CommitCRM.Account> accounts = accountSearch.FetchObjects();

The above line will populate the List (System.Collections.Generic.List) with all CommitCRM.Account objects that were found. Now we can use foreach statement to iterate through the accounts:

foreach (CommitCRM.Account account in accounts)
{
    Console.Out.WriteLine(account.CompanyName);
}

Or we can manipulate these accounts:

foreach (CommitCRM.Account account in accounts)
{
    if (account.Zip.Length == 0)
    {
        account.Zip = "10001";
        account.Save();
    }
}


We invoke the CommitCRM.Account's Save method on both new or existing accounts. For a new account, invoking the Save method would insert a new account in the CommitCRM database. For an existing account, invoking the Save method would update the fields we modified in the existing account. This rule applies to all CommitCRM objects.

Another option is to add a new ticket for each of the accounts:

foreach (CommitCRM.Account account in accounts)
{
    CommitCRM.Ticket ticket = new CommitCRM.Ticket();
    ticket.AccountREC_ID = account.AccountREC_ID;
    ticket.Description = "Sample ticket for a NewYork account";
    ticket.Save();
}

GetFieldValue and SetFieldValue methods

Each of the CommitCRM library objects have a set of properties that are exposed as C# properties that you can directly manipulate or read from. You already saw few examples of these properties in the above examples, as: account.Zip or ticket.Description. This is the preferred and more intuitive way of accessing the CommitCRM fields.


However, there is also another way of achieving the same results, by invoking GetFieldValue and SetFieldValue and specifying the internal field name. These methods should only be used if necessary, for example, when updating user-defined custom fields which are not part of the class predefined basic fields.

Here is an equivalent of the above example that uses these two generic methods, instead of the object's properties:

foreach (CommitCRM.Account account in accounts)
{
    CommitCRM.Ticket ticket = new CommitCRM.Ticket();
    ticket.SetFieldValue("FLDTKTCARDID", account.GetFieldValue("FLDCRDRECID"));
    ticket.SetFieldValue("FLDTKTPROBLEM", "Sample ticket for a NewYork account");
    ticket.Save();
}

All internal field names are listed in Classes and Objects below.

Exception Handling

While working with the CommitCRM C# library, some operations can fail. In this case the library will throw an exception of the CommitCRM.Exception class. We recommend enclosing all calls to the CommitCRM library in a try/catch block.

To find out more about the exact error that ocured when an exception is thrown, you can inspect the CommitCRM.Exception.Status property that holds the last CommitCRM Status value, or inspect the list of CommitCRM.Exception.Codes (if any). Please refer to Error Codes Description for the description of these values.

Complete Program Sample

using System;
using System.Collections.Generic;
using System.Text;

namespace CommitCRM_CSharp
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                CommitCRM.Config config = new CommitCRM.Config();
                config.AppName = "C# Demo";
                config.CommitDllFolder = "C:\\Commit\\ThirdParty\\UserDev";
                config.CommitDbFolder = "C:\\Commit\\db";

                CommitCRM.Application.Initialize(config);

                //At this point we have successfully initialized the CommitCRM.Application
                //and can start using the other library classes

                CommitCRM.ObjectQuery<CommitCRM.Account> accountSearch = new CommitCRM.ObjectQuery<CommitCRM.Account>();
                accountSearch.AddCriteria(CommitCRM.Account.Fields.City, CommitCRM.OperatorEnum.opEqual, "New York");
                List<CommitCRM.Account> accounts = accountSearch.FetchObjects();

                foreach (CommitCRM.Account account in accounts)
                {
                    Console.Out.WriteLine(account.CompanyName);
                }
            }
            catch (CommitCRM.Exception exc)
            {
               //here we catch commit specific error
               //we can inspect the Commit status (exc.Status) 
               //exc.Codes contains all error codes last call generated

               //here we show the error message
                Console.Out.Write(exc.Message);
            }
            catch (Exception exc)
            {
                Console.Out.Write(exc.Message);
            }
            finally
            {
                CommitCRM.Application.Terminate();
            }
        }
    }
}

Classes and Objects

The CommitCRM C# API provides easy access to all objects using a class for each entity in the system (such as Account, Ticket, Asset, etc.).

All classes include:

  1. API functions and routines (which are derived from the base CommitCRM.Object class).
  2. Class data fields, providing an easy way to update the object's data.


All CommitCRM's objects should be updated by setting the class data fields (properties) and then calling the Save method. For example, to create a new account programmatically (assuming CommitCRM.Application was initialized successfully), one would use the following code snippet:

CommitCRM.Account account = new CommitCRM.Account();
account.FileAs = "ACME Company";
account.Dear = "Mr.";
account.Contact = "John Doe";
account.Save();


Another option is using SetFieldData and GetFieldData as mentioned earlier, which provide low-level access to data fields. This option should only be used if necessary, for example, when updating user-defined fields which are not part of the class basic fields.


Object Class

The CommitCRM.Object class is the base class for all CommitCRM accessible objects (as Ticket, Account, Asset, etc.). The public methods exposed by the CommitCRM.Object class are available to the derived classes.

Object Method Reference Table

Access modifier Return value Method Arguments Description
public void SetFieldValue (string sKey, string sValue) Assigns the value (sValue) of the field passed in sKey argument. Save must be called for the change to take effect. Use this method to access user-defined custom fields.
public string GetFieldValue (string sKey) Retrieves the value of the field passed in sKey argument. Use this method to access user-defined custom fields.
public void Reload () Reloads the Object values from the database. The value of the object unique identifier (REC_ID, the exact name depends on the concrete derived object class)
public void Reinit (string sID) Same as Reload except the unique identifier is passed as argument.
public void Save () Saves all modified properties of the object to the database.

Object derived classes

Classes explained in this section are derived from CommitCRM.Object class and map directly to a native Commit CRM object (Account, Ticket, etc.).

Account Class

The CommitCRM.Account class derives from CommitCRM.Object and encapsulates the Account Fields. The following table lists all exposed CommitCRM.Account properties.

Account Properties Reference Table

Access modifier Return value Property API Field Name Field length
public string AccountREC_ID FLDCRDRECID 20
public string AccountManager FLDCRDASSIGNCARDID 20
public string CompanyName FLDCRDCOMPANY 60
public string Contact FLDCRDCONTACT 40
public string Assistant FLDCRDASSISTANT 20
public string ContractREC_ID FLDCRDBCRECID 20
public string AccountNumber FLDCRDCARDID2 15
public string ID FLDCRDCARDID3 15
public string PopupMessage FLDCRDCARDMESSAGE Unlimited
public string AddressLine1 FLDCRDADDRESS1 40
public string AddressLine2 FLDCRDADDRESS2 40
public string AddressLine3 FLDCRDADDRESS3 40
public string City FLDCRDCITY 30
public string Country FLDCRDSTATE 20
public string State FLDCRDCOUNTRY 30
public string Zip FLDCRDZIP 15
public DateTime CreationDate FLDCRDCREATEDATE N/A
public string CreatedByUser FLDCRDCREATEUSERID 20
public string Dear FLDCRDDEAR 20
public string Department FLDCRDDEPARTMENT 35
public string DocumentsStoreDirectory FLDCRDDOCSFOLDER 100
public string EmailAddress1 FLDCRDEMAIL1 70
public string EmailAddress2 FLDCRDEMAIL2 70
public int AccountType FLDCRDENTITYKIND N/A
public FaxNumber FLDCRDFAX1 string 25
public FaxNumberExt FLDCRDFAXDESC1 string 15
public string FileAs FLDCRDFULLNAME 60
public string Type FLDCRDKIND 30
public LastName FLDCRDLASTNAME string 20
public Notes FLDCRDNOTES string Unlimited
public Field FLDCRDPERSONID string 20
public string Phone1Ext FLDCRDPHNDESC1 40
public string Phone2Ext FLDCRDPHNDESC2 40
public string Phone3Ext FLDCRDPHNDESC3 15
public string Phone4Ext FLDCRDPHNDESC4 15
public string Phone1 FLDCRDPHONE1 25
public string Phone2 FLDCRDPHONE2 25
public string Phone3 FLDCRDPHONE3 25
public string Phone4 FLDCRDPHONE4 25
public string Region FLDCRDREGIONCODE 15
public string PopupMessageDisplayIndication FLDCRDSHOWMESSAGE 1
public string SubContractCode FLDCRDSUBCODE 15
public string Salutation FLDCRDSUFFIX 20
public string Tax1 FLDCRDTAXCODE1 3
public string Tax2 FLDCRDTAXCODE2 3
public string Title FLDCRDTITLE 30
public string LastUpdatedBy FLDCRDUPDATEUSERID 20
public string WebAddress1 FLDCRDURL1 100
public string WebAddress2 FLDCRDURL2 100
public string Status FLDCRDUSER1 30
public string Field1 FLDCRDUSER2 30
public string Field2 FLDCRDUSER3 30
public string Field3 FLDCRDUSER4 30
public string Field4 FLDCRDUSER5 30

Ticket Class

The CommitCRM.Ticket class derives from CommitCRM.Object and encapsulates the Ticket Fields. The following table lists all exposed CommitCRM.Ticket properties.

Ticket Properties Reference Table

Access modifier Property API Field Name Return value Field length
public TicketREC_ID FLDTKTRECID string 20
public AccountREC_ID FLDTKTCARDID string 20
public AssetREC_ID FLDTKTASSETRECID string 20
public ContactREC_ID FLDTKTCONTACTID string 20
public ContractREC_ID FLDTKTBCRECID string 20
public EmployeeREC_ID FLDTKTWORKERID string 20
public TicketPriority FLDTKTPRIORITY int N/A
public TicketNumber FLDTKTTICKETNO string 20
public Description FLDTKTPROBLEM string Unlimited
public TicketType FLDTKTKIND string 25
public Source FLDTKTSOURCE string 30
public EstimatedDurationTime FLDTKTSCHEDLENESTIM int N/A
public ShowTicketInDispatcher FLDTKTFORDISPATCH string 1
public Status FLDTKTSTATUS int N/A
public CreatedByUser FLDTKTCREATEUSER string 20
public DueDate FLDTKTDUEDATETIME DateTime N/A
public Resolution FLDTKTSOLUTION string Unlimited
public UpdateDate FLDTKTUPDATEDATE DateTime N/A

Asset Class

The CommitCRM.Asset class derives from CommitCRM.Object and encapsulates the Asset Fields. The following table lists all exposed CommitCRM.Asset properties.

Asset Properties Reference Table

Access modifier Property API Field Name Return value Field length
public AssetREC_ID FLDASTRECID string 20
public AssetCode FLDASTASSETCODE string 30
public AssetType FLDASTASSETTYPE string 1
public AssetName FLDASTNAME string 60
public Status FLDASTSTATUS string 1
public SerialNo FLDASTSERIALNO string 30
public AccountREC_ID FLDASTACCRECID string 20
public ContactREC_ID FLDASTCONTACTRECID string 20
public CreatedByUser FLDASTCREATEUSER string 20
public PurchaseDate FLDASTCUSTPURDATE DateTime N/A
public PurchasedFromUs FLDASTCUSTPURFROMUS string 1
public PurchaseInvoice FLDASTCUSTPUROURINV string 15
public CustomerPO FLDASTCUSTPURPO string 15
public PurchasePrice FLDASTCUSTPURPRICE double N/A
public DeliveredDate FLDASTDELIVEDATE DateTime N/A
public Description FLDASTDESC string Unlimited
public InstalledBy FLDASTINSTALBY string 20
public InstalledDate FLDASTINSTALDATE DateTime N/A
public LicenseCodes FLDASTLICENSECODE string Unlimited
public LicenseKeys FLDASTLICENSEKEYS string Unlimited
public LicenseNotes FLDASTLICENSENOTES string Unlimited
public Location FLDASTLOCATION string 50
public Manufacturer FLDASTMANUFACTURER string 40
public MnfSerialNo FLDASTMNFSERIALNO string 30
public Model FLDASTMODEL string 20
public Notes FLDASTNOTES string Unlimited
public Quantity FLDASTQUANTITY double N/A
public LastUpdateBy FLDASTUPDATEUSER string 20
public Field1 FLDASTUSER1 string 25
public Field2 FLDASTUSER2 string 25
public Field3 FLDASTUSER3 string 25
public Field4 FLDASTUSER4 string 25
public Field5 FLDASTUSER5 string 25
public Date1 FLDASTUSERDATE1 DateTime N/A
public Number1 FLDASTUSERNUMBER1 double N/A
public VendorPurchasedDate FLDASTVENDORDATEPURC DateTime N/A
public VendorInvoice FLDASTVENDORINVNO string 15
public VendorPO FLDASTVENDOROURPO string 15
public VendorPrice FLDASTVENDORPRICE double N/A
public Vendor FLDASTVENDORRECID string 20
public VendorSerialNo FLDASTVENDORSERNO string 30
public VendorWarrantyExpDate FLDASTVENDORWARREXP DateTime N/A
public Version FLDASTVERSION string 15
public WarrantyLicenseExp FLDASTWARREXPDATE DateTime N/A

Calendar Class

The CommitCRM.Calendar class derives from CommitCRM.Object and encapsulates the Calendar Fields. The following table lists all exposed CommitCRM.Calendar properties.

Calendar Properties Reference Table

Access modifier Property API Field Name Return value Field length
public CalendarREC_ID FLDEVTRECID string 20
public EventType FLDEVTWRITETOID int N/A
public EmployeeREC_ID FLDEVTWORKERID string 20
public PrivateUser FLDEVTPRIVATEID string 20
public AccountREC_ID FLDEVTCARDID string 20
public ContactREC_ID FLDEVTCONTACTID string 20
public DocumentREC_ID FLDEVTDOCID string 20
public DoneIndication FLDEVTDONE bool N/A
public Date FLDEVTEVENTDATE DateTime N/A
public Description FLDEVTFREETEXT string Unlimited
public TimeStart FLDEVTFROMTIME string N/A
public TimeEnd FLDEVTTOTIME string N/A
public RelLinkREC_ID FLDEVTLINKRECID string 20
public Field1 FLDEVTFAMILY string 50
public Field2 FLDEVTACTION string 50
public Field3 FLDEVTPLACE string 40
public Field4 FLDEVTPLACE1 string 30
public Field5 FLDEVTPLACE2 string 30
public CreatedByUser FLDEVTCREATEUSERID string 20
public LastUpdateByUser FLDEVTUPDATEUSER string 20

Charge Class

The CommitCRM.Charge class derives from CommitCRM.Object and encapsulates the Charge Fields. The following table lists all exposed CommitCRM.Charge properties.

Charge Properties Reference Table

Access modifier Property API Field Name Return value Field length
public ChargeREC_ID FLDSLPRECID string 20
public ChargeSource FLDSLPSOURCERECID string 20
public AccountREC_ID FLDSLPCARDID string 20
public EmployeeREC_ID FLDSLPWORKERID string 20
public ChargedItem FLDSLPITEMID string 20
public ContractREC_ID FLDSLPBCRECID string 20
public TicketREC_ID FLDSLPTICKETID string 20
public [Date] FLDSLPSLIPDATE DateTime N/A
public Description FLDSLPDESC string Unlimited
public Units_Hours FLDSLPQUANTITY double N/A
public AdjustAmount FLDSLPADJUSTAMOUNT double N/A
public AdjustPercent FLDSLPADJUSTPERCENT double N/A
public FromTime FLDSLPSTARTTIME string N/A
public ToTime FLDSLPENDTIME string N/A
public Price_Rate FLDSLPPRICE double N/A
public Billable FLDSLPBILLKIND string 1
public Billed FLDSLPSTAGE string 1
public Field1 FLDSLPUSER1 string 25
public CreateUser FLDSLPCREATEUSER string 20

Document Class

The CommitCRM.Document class derives from CommitCRM.Object and encapsulates the Document Fields. The following table lists all exposed CommitCRM.Document properties.

Document Properties Reference Table

Access modifier Property API Field Name Return value Field length
public DocumentREC_ID FLDDOCRECID string 20
public DocumentDate FLDDOCDOCDATE DateTime N/A
public Subject FLDDOCDOCUMENTDESC string 100
public RelLinkREC_ID FLDDOCLINKRECID string 20
public AccountREC_ID FLDDOCCARDID string 20
public ContactREC_ID FLDDOCCONTACTID string 20
public Field1 FLDDOCTRANSPORT string 20
public Field2 FLDDOCFOLDER string 20
public Field3 FLDDOCUMENTPLACE string 20
public FilePathAndName FLDDOCDOCUMENTNAME string 240
public Category FLDDOCTREEID int N/A
public EmployeeREC_ID FLDDOCWORKERID string 20
public CreatedByUser FLDDOCCREATEUSER string 20
public LastUpdateByUser FLDDOCUPDATEUSER string 20

HistoryNote Class

The CommitCRM.HistoryNote class derives from CommitCRM.Object and encapsulates the History Note Fields. The following table lists all exposed CommitCRM.HistoryNote properties.

HistoryNote Properties Reference Table

Access modifier Property API Field Name Return value Field length
public HistoryNoteREC_ID FLDHISRECID string 20
public Date FLDHISNOTEDATETIME DateTime N/A
public Description FLDHISDESCRIPTION string Unlimited
public RelLinkREC_ID FLDHISLINKRECID string 20
public Field FLDHISUSER1 string 25
public About FLDHISKIND string 15
public EmployeeREC_ID FLDHISWORKERID string 20
public AccountREC_ID FLDHISCARDID string 20
public Contact FLDHISCONTACTID string 20
public DocumentREC_ID FLDHISDOCID string 20
public CreatedByUser FLDHISCREATEUSER string 20

Item Class

The CommitCRM.Item class derives from CommitCRM.Object and encapsulates the Item Fields. The following table lists all exposed CommitCRM.Item properties.

Item Properties Reference Table

Access modifier Property API Field Name Return value Field length
public ItemREC_ID FLDITMRECID string 20
public ItemGroup FLDITMITEMTYPEGROUP string 1
public ItemCode FLDITMITEMNO string 30
public ItemName FLDITMNAME string 60
public PriceSource FLDITMPRICESOURCE string 1
public PricePerHour_Unit FLDITMUNITISHOUR string 1
public Price FLDITMUNITPRICE double N/A
public Cost FLDITMSTANDARDCOST double N/A
public Tax1 FLDITMTAXCODE1 string 3
public Tax2 FLDITMTAXCODE2 string 3
public Tax3 FLDITMTAXCODE3 string 3
public DescriptionByName FLDITMDESCBYNAME string 1
public Description FLDITMDESC string Unlimited
public Suspend FLDITMSUSPENDED string 1
public Notes FLDITMNOTES string Unlimited
public Field1 FLDITMUSER1 string 25
public CreateUser FLDITMCREATEUSER string 20

KnowledgeBaseArticle Class

The CommitCRM.KnowledgeBaseArticle class derives from CommitCRM.Object and encapsulates the Knowledge Base Article Fields. The following table lists all exposed CommitCRM.KnowledgeBaseArticle properties.

KnowledgeBaseArticle Properties Reference Table

Access modifier Property API Field Name Return value Field length
public KnowledgeBaseArticleREC_ID FLDKBARECID string 20
public DocumentDate FLDKBACREATEDATE DateTime N/A
public Title FLDKBATITLE string 250
public Problem FLDKBAPROBLEM string Unlimited
public Solution FLDKBASOLUTION string Unlimited
public Status FLDKBASTATUS string 1
public Category FLDKBACATEGORY string 100
public [Public] FLDKBAISPUBLIC string 1
public CreatedByUser FLDKBACREATEUSER string 20
public LastUpdateByUser FLDKBAUPDATEUSER string 20

Opportunity Class

The CommitCRM.Opportunity class derives from CommitCRM.Object and encapsulates the Opportunity Fields. The following table lists all exposed CommitCRM.Opportunity properties.

Opportunity Properties Reference Table

Access modifier Property API Field Name Return value Field length
public OpportunityREC_ID FLDOPPRECID string 20
public OpportunityName FLDOPPNAME string 50
public OpportunityID FLDOPPUSERID string 15
public AccountREC_ID FLDOPPCARDID string 20
public Source FLDOPPSOURCE string 30
public CloseDate FLDOPPCLOSEDATE DateTime N/A
public Manager FLDOPPWORKERID string 20
public OpenDate FLDOPPOPENDATE DateTime N/A
public CloseByDate FLDOPPESTDATE DateTime N/A
public Amount FLDOPPAMOUNT double N/A
public Probability FLDOPPPROBABILITY double N/A
public Stage FLDOPPSTAGE string 30
public Status FLDOPPSTATUS int N/A
public ClosingAmount FLDOPPCLOSEAMOUNT double N/A
public Description FLDOPPDESCRIPTION string Unlimited
public OpportunityType FLDOPPKIND string 30
public OpportunityReason FLDOPPREASON string 30
public Note FLDOPPNOTES string Unlimited
public Territory FLDOPPREGION string 30
public Field1 FLDOPPUSER1 string 30
public Field2 FLDOPPUSER2 string 30
public Field3 FLDOPPUSER3 string 30
public CreatedByUser FLDOPPCREATEUSER string 20
public LastUpdateByUser FLDOPPUPDATEUSER string 20

Config Class

CommitCRM.Config class is used to pass the global configuration settings to the CommitCRM.Application Initialize method.

Property Type Required Description
AppName string Yes Maximum 15 chars, string that best identifies your application.
CommitDllFolder string Yes Exact path to the folder where CommitCRM API DLLs are located (CmtDbEng.dll and CmtDbQry.dll, usually "C:\\Commit\\ThirdParty\\UserDev").
CommitDbFolder String Yes Exact path to the folder where CommitCRM database is located (usually "C:\\Commit\\db").
InitCommitApiDll Boolean No Initializes the CmtDbEng.dll file, which is required for proper functioning of all update functions. true by default (recommended setting). Set it to false only if you know what you are doing.
InitCommitQryDll bool No Initializes the CmtDbQry.dll file which is required for proper functioning of all search/query functions. true by default (recommended setting). Set it to false only if you know what you are doing.
Params List<string,string> No Not used, reserved for future use
RaiseExceptionIfDatabaseFieldTruncated bool No Specifies whether truncation of a field value will raise an exception. All string properties/fields have length limitations and if you overwrite them, the extra chars will be removed. By default this setting is False. Set it to True if you want truncation to raise an exception.

Application Class

The CommitCRM.Application class implements a Singleton pattern that hold all global defined application settings and is used for easy access to these settings. Once the main CommitCRM.Application object is initialized, you can refer to this instance by writing: CommitCRM.Application.instance().

Table below lists the CommitCRM.Application properties.

Property Type Description
config Config Access to the CommitCRM.Config object passed in CommitCRM.Application.Initialize method.
CmtDateFormat String Global CommitCRM date format (as dd/mm/yyyy or mm/dd/yyyy). You'll need to refer to this setting if you are directly manipulating DateTime field (using SetFieldValue method).
CmtDateSeparator String Separator between the date ranges, usually '/', '-' or '.'.
CmtTimeFormat String Global CommitCRM time format.
CmtIsTimeFormatAMPMInUse Boolean 12 hour or 24 hour time format.

Table below list the CommitCRM.Application methods.

Access modifier Return value Method Arguments Description
public static Application instance () Method that returns the singleton object. Use it to access all CommitCRM.Application properties/methods.
public static void Initialize (Config c) Method that initializes the internal CommitCRM API DLLs. Must be the first call before using any other CommitCRM library calls.
public static void Terminate () Terminates all CommitCRM internal resources. You should call this method before exit from your application.