C++ API

From RangerMSP Wiki - PSA software for MSPs and IT services providers
Jump to: navigation, search

Disclaimer

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

Introduction

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


System Requirements

  • RangerMSP 5.6 or later.
  • Visual C++ 2008 or Visual C++ 2010.
  • CRMLib C++ header files.
  • CRMLib.lib (the RangerMSP C++ static library).


Getting Started

Libraries Setup

To download, compile and setup the libraries, please refer to C++ API Library Setup.

Start Basic Program

After you create your C++ project, you'll need to add the RangerMSP Source folder to your include path and link with the CRMLib.lib static library file, in order to have access to the RangerMSP library classes.

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

Connecting to the RangerMSP database can be done in two ways:

  1. Using a Local Server - run your program on the same server where the RangerMSP Server runs.
  2. Using Web API - run your program anywhere and connect to a remote RangerMSP server over Web services interface.

Connection parameters vary between these options. See the variations below:

Local Server

For connections to a local RangerMSP server configure the following settings:

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

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

CRM::Config config;
config.AppName = "C++ Demo";
config.DllFolder = "C:\\RangerMSP\\ThirdParty\\UserDev";
config.DbFolder = "C:\\RangerMSP\\db";

You should of course ensure these paths are correct on your disk and modify the values accordingly.

Remote Server (Web API)

To connect to a remote RangerMSP server with the Web API, configure the following settings:

  • AppName
This is free text, preferably the name of your application.
  • WebAPIUrl
Url to the RangerMSP server running the Web API, either local or remote.
Url must include the http:// or https:// prefix, otherwise the API will not be able to connect.
Valid examples include http://localhost:4964/ and https://webapi.myRangerMSPserver.com/.
  • Password
Your authorization password/token
  • UseWebAPI
Boolean value, must be set to true to use the Web API

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

CRM::Config config;
config.AppName = "C++ Demo";
config.WebAPIUrl = "http://localhost:4964/";
config.Password = "yourpassword";
config.UseWebAPI = true;

Initialization

The configuration settings explained above are the only differences between connecting to a local RangerMSP server or remote RangerMSP server running the Web API.

Now we can initialize the CRM::Application object with these settings:

//RangerMSP.Application.Initialize must be the first call before invoking any other RangerMSP library method
//and it should be done only once in the program's lifetime.
CRM::Application::Initialize(config);

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

Before exit, we terminate the CRM::Application object:

//Before exit we should call RangerMSP.Application.Terminate to gracefully release all application resources
//and this should be done only once in the program's lifetime.
CRM::Application::Terminate();

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

try
{
    CRM::Config config;
    config.AppName = "C++ Demo";
    config.DllFolder = "C:\\RangerMSP\\ThirdParty\\UserDev";
    config.DbFolder = "C:\\RangerMSP\\db";

    CRM::Application::Initialize(config);

    //At this point we have successfully initialized the RangerMSP.Application
    //and can start using the other library classes
}
catch (CRM::Exception exc)
{
    std::cerr << exc.error() << std::endl;
}
CRM::Application::Terminate();

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

The library exposes as C++ classes the same RangerMSP objects (Account, Ticket etc.) available through the native RangerMSP 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 CRM::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 CRM::Account objects. We instantiate an object of the CRM::ObjectQuery class and pass CRM::Account class as generics parameter.

CRM::ObjectQuery<CRM::Account> accountSearch;

CRM::ObjectQuery class can accept any of the RangerMSP 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(CRM::Account::Fields::City, CRM::opEqual, "New York");

Тhe first parameter to the AddCriteria method is either a static object instance of CRM::CrmField 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 CRM::Account class.

The second parameter is a compare operator. We here use the CRM::OperatorEnum::opEqual to get only exact matches. In order to get a broader match in the results you can use CRM::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 CRM::OperatorEnum::opLike operator, will match the phrase even if in the middle of a sentence.

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

CRM::ObjectQuery<CRM::Account>::COLLECTION accounts = accountSearch.FetchObjects();

The above line will populate a list with all CRM::Account objects that were found. Now we can iterate through the accounts like this:

CRM::ObjectQuery<CRM::Account>::COLLECTION::iterator itAccount = accounts.begin();
while (itAccount != accounts.end())
{
    std::cout << account.CompanyName() << "\r\n";
    ++itAccount;
}

Or we can manipulate these accounts:

CRM::ObjectQuery<CRM::Account>::COLLECTION::iterator itAccount = accounts.begin();
while (itAccount != accounts.end())
{
    if (account.Zip().empty())
    {
         account.Zip("10001");
         account.Save();
    }

    ++itAccount;
}


We invoke the CRM::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 RangerMSP database. For an existing account, invoking the Save method would update the fields we modified in the existing account. This rule applies to all RangerMSP objects.

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

CRM::ObjectQuery<CRM::Account>::COLLECTION::iterator itAccount = accounts.begin();
while (itAccount != accounts.end())
{
    CRM::Ticket ticket;
    ticket.AccountREC_ID(account.AccountREC_ID());
    ticket.Description("Sample ticket for a NewYork account");
    ticket.Save();

    ++itAccount;
}

GetFieldValue and SetFieldValue methods

Each of the RangerMSP library objects have a set of methods that are exposed as C++ getters/setters methods that you can use to manipulate or read the data. You already saw few examples of these methods in the above examples, as: account.Zip or ticket.Description. This is the preferred and more intuitive way of accessing the RangerMSP 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 getters/setters methods:

CRM::ObjectQuery<CRM::Account>::COLLECTION::iterator itAccount = accounts.begin();
while (itAccount != accounts.end())
{
    CRM::Ticket ticket;
    ticket.SetFieldValue("FLDTKTCARDID", account.GetFieldValue("FLDCRDRECID"));
    ticket.SetFieldValue("FLDTKTPROBLEM", "Sample ticket for a NewYork account");
    ticket.Save();

    ++itAccount;
}

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

Exception Handling

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

To find out more about the exact error that occurred when an exception is thrown, you can use the CRM::Exception::Status method that returns the last RangerMSP Status value, or use the CRM::Exception.Codes method to return the list of last codes (if any). Please refer to Error Codes Description for the description of these values.

Complete Program Sample

#include "stdafx.h"
#include <iostream>

#include <CRMLib/RangerMSP/Application.h>
#include <CRMLib/RangerMSP/Account.h>
#include <CRMLib/RangerMSP/Ticket.h>
#include <CRMLib/RangerMSP/Charge.h>
#include <CRMLib/RangerMSP/Item.h>
#include <CRMLib/RangerMSP/QueryCommand.h>
#include <CRMLib/Exception.h>

#include <CRMLib/Helper.h>
#include <CRMLib/IO/File.h>

int _tmain(int argc, _TCHAR* argv[])
{
    try
    {
        CRM::Config config;
        config.AppName = "C++ Demo";
        config.DllFolder = "C:\\RangerMSP\\ThirdParty\\UserDev";
        config.DbFolder = "C:\\RangerMSP\\db";

        CRM::Application::Initialize(config);

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

        CRM::ObjectQuery<CRM::Account> accountSearch;
        accountSearch.AddCriteria(CRM::Account::Fields::City, CRM::opEqual, "New York");
        CRM::ObjectQuery<CRM::Account>::COLLECTION accounts = accountSearch.FetchObjects();

        CRM::ObjectQuery<CRM::Account>::COLLECTION::iterator itAccount = accounts.begin();
        while (itAccount != accounts.end())
        {
            std::cout << account.CompanyName() << "\r\n";
            ++itAccount;
        }
    }
    catch (CRM::Exception exc)
    {
        //we can inspect the RangerMSP status (exc.Status) 
        //refer to Error Codes Description
        //exc.Codes contains all error codes last call generated
        //also refer to Error Codes Description
        std::cerr << exc.error() << std::endl;
    }

    //Terminate connection with RangerMSP
    CRM::Application::Terminate();

    return 0;
}

Classes and Objects

The RangerMSP 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 CRM::Object class).
  2. Class data fields, providing an easy way to update the object's data.


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

CRM::Account 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 CRM::Object class is the base class for all RangerMSP accessible objects (as Ticket, Account, Asset, etc.). The public methods exposed by the CRM::Object class are available to the derived classes.

Object Method Reference Table

Access modifier Return value Method Arguments Description
public void SetFieldValue (const std::string& sKey, const std::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 std::string GetFieldValue (const std::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 (const std::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 CRM::Object class and map directly to a native RangerMSP object (Account, Ticket, etc.).

Account Class

The CRM::Account class derives from CRM::Object and encapsulates the Account Fields. The following table lists all exposed CRM::Account getter/setter methods.

Account Properties Reference Table

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

Ticket Class

The CRM::Ticket class derives from CRM::Object and encapsulates the Ticket Fields. The following table lists all exposed CRM::Ticket getter/setter methods.

Ticket Properties Reference Table

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

Asset Class

The CRM::Asset class derives from CRM::Object and encapsulates the Asset Fields. The following table lists all exposed CRM::Asset getter/setter methods.

Asset Properties Reference Table

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

Calendar Class

The CRM::Calendar class derives from CRM::Object and encapsulates the Calendar Fields of event type Appointment. The following table lists all exposed CRM::Calendar getter/setter methods.

Calendar Properties Reference Table

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

Task Class

The CRM::Task class derives from CRM::Object and encapsulates the Calendar Fields of event type Task. The following table lists all exposed CRM::Task getter/setter methods.

Task Properties Reference Table

Access modifier Return value Method name Arguments API Field Name Field length
public std::string TaskREC_ID () FLDEVTRECID 20
public int EventType () FLDEVTWRITETOID N/A
public std::string EmployeeREC_ID () FLDEVTWORKERID 20
public void EmployeeREC_ID (const std::string& val) FLDEVTWORKERID 20
public std::string PrivateUser () FLDEVTPRIVATEID 20
public void PrivateUser (const std::string& val) FLDEVTPRIVATEID 20
public std::string AccountREC_ID () FLDEVTCARDID 20
public void AccountREC_ID (const std::string& val) FLDEVTCARDID 20
public std::string ContactREC_ID () FLDEVTCONTACTID 20
public void ContactREC_ID (const std::string& val) FLDEVTCONTACTID 20
public std::string DocumentREC_ID () FLDEVTDOCID 20
public void DocumentREC_ID (const std::string& val) FLDEVTDOCID 20
public bool DoneIndication () FLDEVTDONE N/A
public void DoneIndication (bool val) FLDEVTDONE N/A
public SYSTEMTIME Date () FLDEVTEVENTDATE N/A
public void Date (const SYSTEMTIME& val) FLDEVTEVENTDATE N/A
public std::string Description () FLDEVTFREETEXT Unlimited
public void Description (const std::string& val) FLDEVTFREETEXT Unlimited
public std::string TimeStart () FLDEVTFROMTIME N/A
public void TimeStart (const std::string& val) FLDEVTFROMTIME N/A
public std::string RelLinkREC_ID () FLDEVTLINKRECID 20
public void RelLinkREC_ID (const std::string& val) FLDEVTLINKRECID 20
public std::string Field1 () FLDEVTFAMILY 50
public void Field1 (const std::string& val) FLDEVTFAMILY 50
public std::string Field2 () FLDEVTACTION 50
public void Field2 (const std::string& val) FLDEVTACTION 50
public std::string Field3 () FLDEVTPLACE 40
public void Field3 (const std::string& val) FLDEVTPLACE 40
public std::string Field4 () FLDEVTPLACE1 30
public void Field4 (const std::string& val) FLDEVTPLACE1 30
public std::string Field5 () FLDEVTPLACE2 30
public void Field5 (const std::string& val) FLDEVTPLACE2 30
public std::string CreatedByUser () FLDEVTCREATEUSERID 20
public void CreatedByUser (const std::string& val) FLDEVTCREATEUSERID 20
public std::string LastUpdateByUser () FLDEVTUPDATEUSER 20
public void LastUpdateByUser (const std::string& val) FLDEVTUPDATEUSER 20

Charge Class

The CRM::Charge class derives from CRM::Object and encapsulates the Charge Fields. The following table lists all exposed CRM::Charge getter/setter methods.

Charge Properties Reference Table

Access modifier Return value Method name Arguments API Field Name Field length
public std::string ChargeREC_ID () FLDSLPRECID 20
public std::string AccountREC_ID () FLDSLPCARDID 20
public void AccountREC_ID (const std::string& val) FLDSLPCARDID 20
public std::string EmployeeREC_ID () FLDSLPWORKERID 20
public void EmployeeREC_ID (const std::string& val) FLDSLPWORKERID 20
public std::string ChargedItem () FLDSLPITEMID 20
public void ChargedItem (const std::string& val) FLDSLPITEMID 20
public std::string ContractREC_ID () FLDSLPBCRECID 20
public void ContractREC_ID (const std::string& val) FLDSLPBCRECID 20
public std::string TicketREC_ID () FLDSLPTICKETID 20
public void TicketREC_ID (const std::string& val) FLDSLPTICKETID 20
public SYSTEMTIME Date () FLDSLPSLIPDATE N/A
public void Date (const SYSTEMTIME& val) FLDSLPSLIPDATE N/A
public std::string Description () FLDSLPDESC Unlimited
public void Description (const std::string& val) FLDSLPDESC Unlimited
public double Units_Hours () FLDSLPQUANTITY N/A
public void Units_Hours (const std::string& val) FLDSLPQUANTITY N/A
public bool HourlyBased () FLDSLPITEMUNITISHOUR N/A
public void HourlyBased (bool val) FLDSLPITEMUNITISHOUR N/A
public double AdjustAmount () FLDSLPADJUSTAMOUNT N/A
public void AdjustAmount (double val) FLDSLPADJUSTAMOUNT N/A
public double AdjustPercent () FLDSLPADJUSTPERCENT N/A
public void AdjustPercent (double val) FLDSLPADJUSTPERCENT N/A
public std::string FromTime () FLDSLPSTARTTIME N/A
public void FromTime (const std::string& val) FLDSLPSTARTTIME N/A
public std::string ToTime () FLDSLPENDTIME N/A
public void ToTime (const std::string& val) FLDSLPENDTIME N/A
public double Price_Rate () FLDSLPPRICE N/A
public void Price_Rate (const std::string& val) FLDSLPPRICE N/A
public std::string Billable () FLDSLPBILLKIND 1
public void Billable (const std::string& val) FLDSLPBILLKIND 1
public std::string Billed () FLDSLPSTAGE 1
public void Billed (const std::string& val) FLDSLPSTAGE 1
public std::string Field1 () FLDSLPUSER1 25
public void Field1 (const std::string& val) FLDSLPUSER1 25
public std::string CreateUser () FLDSLPCREATEUSER 20
public void CreateUser (const std::string& val) FLDSLPCREATEUSER 20



Quote Class

The CRM::Quote class derives from CRM::Object. The following table lists all exposed CRM::Quote properties.

Quote Properties Reference Table

Access modifier Return value Property Arguments API Field Name Field length
public std::string QuoteREC_ID () FLDQTERECID 20
public std::string AccountREC_ID () FLDQTEACCOUNTRECID 20
public void AccountREC_ID (const std::string& val) FLDQTEACCOUNTRECID 20
public std::string Status () FLDQTESTATUS 1
public void Status (const std::string& val) FLDQTESTATUS 1
public std::string BillToAddress () FLDQTEBILLTOADDRESS Unlimited
public void BillToAddress (const std::string& val) FLDQTEBILLTOADDRESS Unlimited
public std::string BillToContactREC_ID () FLDQTECONTACTRECID 20
public void BillToContactREC_ID (const std::string& val) FLDQTECONTACTRECID 20
public SYSTEMTIME QuoteDate () FLDQTEQUOTEDATE N/A
public void QuoteDate (const SYSTEMTIME& val) FLDQTEQUOTEDATE N/A
public std::string ShipToContactREC_ID () FLDQTESHIPTOCONTACT 20
public void ShipToContactREC_ID (const std::string& val) FLDQTESHIPTOCONTACT 20
public std::string ShipToAddress () FLDQTESHIPTOADDRESS Unlimited
public void ShipToAddress (const std::string& val) FLDQTESHIPTOADDRESS Unlimited
public std::string ContractREC_ID () FLDQTEBCRECID 20
public void ContractREC_ID (const std::string& val) FLDQTEBCRECID 20
public std::string HeaderNotes () FLDQTEHEADERNOTES Unlimited
public void HeaderNotes (const std::string& val) FLDQTEHEADERNOTES Unlimited
public std::string FooterNotes () FLDQTEFOOTERNOTES Unlimited
public void FooterNotes (const std::string& val) FLDQTEFOOTERNOTES Unlimited
public double TotalAfterTax () FLDQTETOTALAFTERTAX N/A
public double TotalTax1 () FLDQTETOTALTAX1 N/A
public double TotalTax2 () FLDQTETOTALTAX2 N/A
public double Tax1 () FLDQTETAX1 N/A
public double Tax2 () FLDQTETAX2 N/A
public double TotalAfterDiscount () FLDQTETOTALAFTERDISC N/A
public double Discount () FLDQTEDISCOUNT N/A
public double TotalForCustomer () FLDQTETOTAL4CUSTOMER N/A
public bool IsPublic () FLDQTEISPUBLIC N/A
public void IsPublic (bool val) FLDQTEISPUBLIC N/A
public std::string Audit () FLDQTEAUDIT Unlimited
public int QuoteNumber () FLDQTEQUOTENO N/A
public std::string QuoteName () FLDQTEQUOTENAME 100
public void QuoteName (const std::string& val) FLDQTEQUOTENAME 100
public std::string QuoteReference () FLDQTEREFERENCE 20
public void QuoteReference (const std::string& val) FLDQTEREFERENCE 20
public std::string ManagerRec_ID () FLDQTEWORKERID 20
public void ManagerRec_ID (const std::string& val) FLDQTEWORKERID 20
public std::string QuoteUserField1 () FLDQTEUSER1 30
public void QuoteUserField1 (const std::string& val) FLDQTEUSER1 30
public std::string QuoteUserField2 () FLDQTEUSER2 30
public void QuoteUserField2 (const std::string& val) FLDQTEUSER2 30
public std::string QuoteUserField3 () FLDQTEUSER3 30
public void QuoteUserField3 (const std::string& val) FLDQTEUSER3 30
public std::string QuoteNotes () FLDQTENOTES Unlimited
public void QuoteNotes (const std::string& val) FLDQTENOTES Unlimited
public std::string WonConvertedTo () FLDQTEWONCONVERTEDTO 1
public std::string SignatureEmail () FLDQTECAFREEEMAIL 100
public std::string SignatureName () FLDQTECAFREENAME 50
public std::string SignatureText () FLDQTECAFREESIGNATRE 30
public std::string SignatureIPAddress () FLDQTECAIPADDRESS 15
public SYSTEMTIME SignatureDateAndTime () FLDQTECATIMESTAMP N/A
public std::string SignatureWebUserName () FLDQTECAWEBUSERNAME 70
public std::string SignatureWebUserREC_ID () FLDQTECAWEBUSERRECID 20
public std::string CreatedByUser () FLDQTECREATEUSER 20
public std::string LastUpdateByUser () FLDQTEUPDATEUSER 20
public SYSTEMTIME CreatedDate () FLDQTECREATEDATE N/A
public SYSTEMTIME UpdateDate () FLDQTEUPDATEDATE N/A


QuoteLine Class

The CRM::QuoteLine class derives from CRM::Object. The following table lists all exposed CRM::QuoteLine properties.

QuoteLine Properties Reference Table

Access modifier Return value Property Arguments API Field Name Field length
public std::string QuoteLineREC_ID () FLDQTLRECID 20
public std::string QuoteREC_ID () FLDQTLQUOTERECID 20
public void QuoteREC_ID (const std::string& val) FLDQTLQUOTERECID 20
public std::string ItemREC_ID () FLDQTLITEMRECID 20
public void ItemREC_ID (const std::string& val) FLDQTLITEMRECID 20
public std::string ItemGroup () FLDQTLITEMTYPEGROUP 1
public double Quantity () FLDQTLQUANTITY N/A
public void Quantity (double val) FLDQTLQUANTITY N/A
public double Price () FLDQTLPRICE N/A
public void Price (double val) FLDQTLPRICE N/A
public std::string DiscountMarkup () FLDQTLADJUST 1
public void DiscountMarkup (const std::string& val) FLDQTLADJUST 1
public double DiscountTotalAmountForCustomer () FLDQTLADJAMTDIS4CUST N/A
public double DiscountPercentageForCustomer () FLDQTLADJPERDIS4CUST N/A
public double LineTotal () FLDQTLBILLTOTAL N/A
public double LineTotalForCustomer () FLDQTLTOTAL4CUSTOMER N/A
public std::string LineType () FLDQTLLINETYPE 1
public int LineSortOrder () FLDQTLORDER N/A
public void LineSortOrder (int val) FLDQTLORDER N/A
public double PriceForCustomerAfterMarkup () FLDQTLPRICE4CUSTOMER N/A
public double AdjustAmount () FLDQTLADJUSTAMOUNT N/A
public void AdjustAmount (double val) FLDQTLADJUSTAMOUNT N/A
public double AdjustPercent () FLDQTLADJUSTPERCENT N/A
public void AdjustPercent (double val) FLDQTLADJUSTPERCENT N/A
public std::string AdjustType () FLDQTLADJUSTTYPE 1
public void AdjustType (const std::string& val) FLDQTLADJUSTTYPE 1
public std::string Description () FLDQTLDESCRIPTION Unlimited
public void Description (const std::string& val) FLDQTLDESCRIPTION Unlimited
public std::string CreatedByUser () FLDQTLCREATEUSER 20
public std::string LastUpdateByUser () FLDQTLUPDATEUSER 20
public SYSTEMTIME CreatedDate () FLDQTLCREATEDATE N/A
public SYSTEMTIME UpdateDate () FLDQTLUPDATEDATE N/A

QuoteLine Helper Methods

Besides the get/set methods, QuoteLine supports number of helper methods.

QuoteLine Helper Methods Table

Access modifier Return value Property Arguments Description
public void SetQuoteLineItem (const std::string& sItemREC_ID, double dblQuantity, double dblPrice) Fills the appropriate fields for inserting Item type QuoteLine.
public void SetQuoteLineItemWithDiscount (const std::string& sItemREC_ID, double dblQuantity, double dblPrice, double dblDiscount, bool bByPercent) Fills the appropriate fields for inserting Item type QuoteLine specifying a discount.
public void SetQuoteLineItemWithMarkup (const std::string& sItemREC_ID, double dblQuantity, double dblPrice, double dblMarkup, bool bByPercent) Fills the appropriate fields for inserting Item type QuoteLine specifying a markup.
public void SetQuoteLineText (const std::string& sText) Sets the appropriate field for inserting Text type QuoteLine.
public void MoveLineAboveLine (const QuoteLine& lnAbove) Moves the QuoteLine position above the lnAbove position. The QuoteLine in lnAbove must point to an existing QuoteLine. This method essentially assigns the LineSortOrder property to the same value lnAbove holds and lnAbove is pushed down. You must call Save for the change to become effective.
public void MoveToBottom () Moves the QuoteLine position at the bottom of the Quote. This method essentially assigns the LineSortOrder property to -999 which is the value for the last position in the Quote. You must call Save for the change to become effective.
public void Delete () Deletes the QuoteLine.

Document Class

The CRM::Document class derives from CRM::Object and encapsulates the Document Fields. The following table lists all exposed CRM::Document getter/setter methods.

Document Properties Reference Table

Access modifier Return value Method name Arguments API Field Name Field length
public std::string DocumentREC_ID () FLDDOCRECID 20
public SYSTEMTIME DocumentDate () FLDDOCDOCDATE N/A
public void DocumentDate (const SYSTEMTIME& val) FLDDOCDOCDATE N/A
public std::string Subject () FLDDOCDOCUMENTDESC 100
public void Subject (const std::string& val) FLDDOCDOCUMENTDESC 100
public std::string RelLinkREC_ID () FLDDOCLINKRECID 20
public void RelLinkREC_ID (const std::string& val) FLDDOCLINKRECID 20
public std::string AccountREC_ID () FLDDOCCARDID 20
public void AccountREC_ID (const std::string& val) FLDDOCCARDID 20
public std::string ContactREC_ID () FLDDOCCONTACTID 20
public void ContactREC_ID (const std::string& val) FLDDOCCONTACTID 20
public std::string Field1 () FLDDOCTRANSPORT 20
public void Field1 (const std::string& val) FLDDOCTRANSPORT 20
public std::string Field2 () FLDDOCFOLDER 20
public void Field2 (const std::string& val) FLDDOCFOLDER 20
public std::string Field3 () FLDDOCUMENTPLACE 20
public void Field3 (const std::string& val) FLDDOCUMENTPLACE 20
public std::string FilePathAndName () FLDDOCDOCUMENTNAME 240
public void FilePathAndName (const std::string& val) FLDDOCDOCUMENTNAME 240
public int Category () FLDDOCTREEID N/A
public void Category (int val) FLDDOCTREEID N/A
public std::string EmployeeREC_ID () FLDDOCWORKERID 20
public void EmployeeREC_ID (const std::string& val) FLDDOCWORKERID 20
public std::string CreatedByUser () FLDDOCCREATEUSER 20
public void CreatedByUser (const std::string& val) FLDDOCCREATEUSER 20
public std::string LastUpdateByUser () FLDDOCUPDATEUSER 20
public void LastUpdateByUser (const std::string& val) FLDDOCUPDATEUSER 20

HistoryNote Class

The CRM::HistoryNote class derives from CRM::Object and encapsulates the History Note Fields. The following table lists all exposed CRM::HistoryNote getter/setter methods.

HistoryNote Properties Reference Table

Access modifier Return value Method name Arguments API Field Name Field length
public std::string HistoryNoteREC_ID () FLDHISRECID 20
public SYSTEMTIME Date () FLDHISNOTEDATETIME N/A
public void Date (const SYSTEMTIME& val) FLDHISNOTEDATETIME N/A
public std::string Description () FLDHISDESCRIPTION Unlimited
public void Description (const std::string& val) FLDHISDESCRIPTION Unlimited
public std::string RelLinkREC_ID () FLDHISLINKRECID 20
public void RelLinkREC_ID (const std::string& val) FLDHISLINKRECID 20
public std::string Field () FLDHISUSER1 25
public void Field (const std::string& val) FLDHISUSER1 25
public std::string About () FLDHISKIND 15
public void About (const std::string& val) FLDHISKIND 15
public std::string EmployeeREC_ID () FLDHISWORKERID 20
public void EmployeeREC_ID (const std::string& val) FLDHISWORKERID 20
public std::string AccountREC_ID () FLDHISCARDID 20
public void AccountREC_ID (const std::string& val) FLDHISCARDID 20
public std::string Contact () FLDHISCONTACTID 20
public void Contact (const std::string& val) FLDHISCONTACTID 20
public std::string DocumentREC_ID () FLDHISDOCID 20
public void DocumentREC_ID (const std::string& val) FLDHISDOCID 20
public std::string CreatedByUser () FLDHISCREATEUSER 20
public void CreatedByUser (const std::string& val) FLDHISCREATEUSER 20

Item Class

The CRM::Item class derives from CRM::Object and encapsulates the Item Fields. The following table lists all exposed CRM::Item getter/setter methods.

Item Properties Reference Table

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

KnowledgeBaseArticle Class

The CRM::KnowledgeBaseArticle class derives from CRM::Object and encapsulates the Knowledge Base Article Fields. The following table lists all exposed CRM::KnowledgeBaseArticle getter/setter methods.

KnowledgeBaseArticle Properties Reference Table

Access modifier Return value Method name Arguments API Field Name Field length
public std::string KnowledgeBaseArticleREC_ID () FLDKBARECID 20
public SYSTEMTIME DocumentDate () FLDKBACREATEDATE N/A
public void DocumentDate (const SYSTEMTIME& val) FLDKBACREATEDATE N/A
public std::string Title () FLDKBATITLE 250
public void Title (const std::string& val) FLDKBATITLE 250
public std::string Problem () FLDKBAPROBLEM Unlimited
public void Problem (const std::string& val) FLDKBAPROBLEM Unlimited
public std::string Solution () FLDKBASOLUTION Unlimited
public void Solution (const std::string& val) FLDKBASOLUTION Unlimited
public std::string Status () FLDKBASTATUS 1
public void Status (const std::string& val) FLDKBASTATUS 1
public std::string Category () FLDKBACATEGORY 100
public void Category (const std::string& val) FLDKBACATEGORY 100
public std::string Public () FLDKBAISPUBLIC 1
public void Public (const std::string& val) FLDKBAISPUBLIC 1
public std::string CreatedByUser () FLDKBACREATEUSER 20
public void CreatedByUser (const std::string& val) FLDKBACREATEUSER 20
public std::string LastUpdateByUser () FLDKBAUPDATEUSER 20
public void LastUpdateByUser (const std::string& val) FLDKBAUPDATEUSER 20

Opportunity Class

The CRM::Opportunity class derives from CRM::Object and encapsulates the Opportunity Fields. The following table lists all exposed CRM::Opportunity getter/setter methods.

Opportunity Properties Reference Table

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

Contact Class

The CRM::Contact class derives from CRM::Object and it represents the secondary contacts to a CRM::Account. The following table lists all exposed CRM::Contact getter/setter methods.

Contact Properties Reference Table

Access modifier Return value Method name Arguments API Field Name Field length
public std::string ContactREC_ID () FLDCRDRECID 20
public std::string ParentAccountREC_ID () FLDCRDASSIGNCARDID 20
public void ParentAccountREC_ID (const std::string& val) FLDCRDASSIGNCARDID 20
public int AccountType () FLDCRDENTITYKIND N/A
public void AccountType (int val) FLDCRDENTITYKIND N/A
public std::string CompanyName () FLDCRDCOMPANY 60
public void CompanyName (const std::string& val) FLDCRDCOMPANY 60
public std::string Contact () FLDCRDCONTACT 40
public void Contact (const std::string& val) FLDCRDCONTACT 40
public std::string Salutation () FLDCRDSUFFIX 20
public void Salutation (const std::string& val) FLDCRDSUFFIX 20
public std::string Title () FLDCRDTITLE
public void Title (const std::string& val) FLDCRDTITLE
public std::string Department () FLDCRDDEPARTMENT 35
public void Department (const std::string& val) FLDCRDDEPARTMENT 35
public std::string Dear () FLDCRDDEAR 20
public void Dear (const std::string& val) FLDCRDDEAR 20
public std::string LastName () FLDCRDLASTNAME 20
public void LastName (const std::string& val) FLDCRDLASTNAME 20
public std::string AddressLine1 () FLDCRDADDRESS1 40
public void AddressLine1 (const std::string& val) FLDCRDADDRESS1 40
public std::string AddressLine2 () FLDCRDADDRESS2 40
public void AddressLine2 (const std::string& val) FLDCRDADDRESS2 40
public std::string AddressLine3 () FLDCRDADDRESS3 40
public void AddressLine3 (const std::string& val) FLDCRDADDRESS3 40
public std::string City () FLDCRDCITY 30
public void City (const std::string& val) FLDCRDCITY 30
public std::string Country () FLDCRDCOUNTRY 20
public void Country (const std::string& val) FLDCRDCOUNTRY 20
public std::string Zip () FLDCRDZIP 15
public void Zip (const std::string& val) FLDCRDZIP 15
public std::string State () FLDCRDSTATE 30
public void State (const std::string& val) FLDCRDSTATE 30
public std::string EmailAddress1 () FLDCRDEMAIL1 70
public void EmailAddress1 (const std::string& val) FLDCRDEMAIL1 70
public std::string Phone1 () FLDCRDPHONE1 25
public void Phone1 (const std::string& val) FLDCRDPHONE1 25
public std::string Phone2 () FLDCRDPHONE2 25
public void Phone2 (const std::string& val) FLDCRDPHONE2 25
public std::string FaxNumber () FLDCRDFAX1 25
public void FaxNumber (const std::string& val) FLDCRDFAX1 25
public std::string Phone1Ext () FLDCRDPHNDESC1 40
public void Phone1Ext (const std::string& val) FLDCRDPHNDESC1 40
public std::string Phone2Ext () FLDCRDPHNDESC2 40
public void Phone2Ext (const std::string& val) FLDCRDPHNDESC2 40
public std::string FaxNumberExt () FLDCRDFAXDESC1 15
public void FaxNumberExt (const std::string& val) FLDCRDFAXDESC1 15
public std::string SubContractCode () FLDCRDSUBCODE 15
public void SubContractCode (const std::string& val) FLDCRDSUBCODE 15
public SYSTEMTIME Birthday () FLDCRDBIRTHDAY N/A
public void Birthday (const SYSTEMTIME& val) FLDCRDBIRTHDAY N/A
public std::string Notes () FLDCRDNOTES Unlimited
public void Notes (const std::string& val) FLDCRDNOTES Unlimited
public SYSTEMTIME CreationDate () FLDCRDCREATEDATE N/A
public void CreationDate (const SYSTEMTIME& val) FLDCRDCREATEDATE N/A
public std::string CreatedByUser () FLDCRDCREATEUSERID 20
public void CreatedByUser (const std::string& val) FLDCRDCREATEUSERID 20
public std::string LastUpdatedBy () FLDCRDUPDATEUSERID 20
public void LastUpdatedBy (const std::string& val) FLDCRDUPDATEUSERID 20

Config Class

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

Return value Method name Required Description
std::string AppName Yes Maximum 15 chars, string that best identifies your application.
std::string DllFolder Yes Exact path to the folder where RangerMSP API DLLs are located (CmtDbEng.dll and CmtDbQry.dll, usually "C:\\RangerMSP\\ThirdParty\\UserDev").
std::string DbFolder Yes Exact path to the folder where RangerMSP database is located (usually "C:\\RangerMSP\\db").
bool InitCRMApiDll 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.
bool InitCRMQryDll 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 std::vector<std::pair<std::string,std::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 CRM::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 RangerMSP.Application object is initialized, you can refer to this instance by writing: CRM::Application::instance().

Table below lists the CRM::Application getter methods.

Access modifier Return value Method name Arguments Description
public const Config& config () Access to the CRM::Config object passed in CRM::Application.Initialize method.
public std::string CmtDateFormat () Global RangerMSP 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).
public std::string CmtDateSeparator () Separator between the date ranges, usually '/', '-' or '.'.
public std::string CmtTimeFormat () Global RangerMSP time format.
public bool CmtIsTimeFormatAMPMInUse () 12 hour or 24 hour time format.

Table below list the CRM::Application methods.

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

CrmField Class

The CRM::CrmField class holds the basic attributes for each database field. For each of the classes that represent RangerMSP objects (Account, Ticket, etc.) there is a preinitialized set of shared CRM::CrmField objects that correspond to the properties defined for the class. For example, the CRM::Account class has a getter method FileAs (CRM::Account::FileAs). To this methodcorresponds one static object instance of the CRM::CrmField class accessible through CRM::Account::Fields::FileAs. To the getter methodLastName (CRM::Account::LastName), corresponds the static object CRM::Account::Fields::LastName of type CRM::CrmField. And so on, for each getter method in each class.

Below is a table that lists the getter methods available in the CRM::CrmField class.

Access modifier Return value Method name Arguments Description
public std::string Key () The internal database field key (as FLDCRDFULLNAME or FLDCRDLASTNAME, etc.)
public std::string Type () Internal database field type (as CHAR, MEMO, DOUBLE, TIMESTAMP, etc.)
public int Size () Maximum allowed length for the field data (applies to CHAR Type).
public std::string Label () Label for the field
public std::string Hint ()
public std::string Name ()
public std::string DefaultValue () Default value for the field
public std::string DisplaySymbol () For fields that represent currency value this can be $ (for dollar), or for percentage values this can be %

We demonstrate the above in the following sample:

//charge is of type CRM::Charge and is previously initialized
std::cout << charge.AdjustAmount << CRM::Charge::Fields::AdjustAmount.DisplaySymbol());

ObjectQuery Class

CRM::ObjectQuery is a template class that can operate with any of the CRM::Object derived classes. It is used to query for objects of certain type (Account, Ticket, etc.). For example, the following code snippet searches for all tickets of an account updated since certain date:

CRM::ObjectQuery<CRM::Ticket> ticketSearch;
//account is previously initialized
ticketSearch.AddCriteria(CRM::Ticket::Fields.AccountREC_ID, CRM::opEqual, account.AccountREC_ID());
SYSTEMTIME time;
ZeroMemory(&time, sizeof(time));
time.wYear = 2011;
time.wMonth = 1;
time.wDay = 1;
ticketSearch.AddCriteria(CRM::Ticket::Fields.UpdateDate, CRM::opGreaterThanOrEqual, time));
CRM::ObjectQuery<CRM::Ticket>::COLLECTION tickets = ticketSearch.FetchObjects();
//tickets now contains all CRM::Ticket objects that satisfy the above criteria.


By default, RangerMSP.ObjectQuery.AddCriteria method uses the logical AND operator to link the conditions. Thus, in case more than one condition are added, all have to be satisfied in order for an object to get into the search results.

In case we want to search for objects and it is enough to satisfy any of the criteria, we can use the OR operator, as in the example below:

CRM::ObjectQuery<CRM::Account> accountSearch(CRM::linkOR);
accountSearch.AddCriteria(CRM::Account::Fields.City, CRM::opEqual, "New York");
accountSearch.AddCriteria(CRM::Account::Fields.City, CRM::opEqual, "Chicago");
CRM::ObjectQuery<CRM::Account>::COLLECTION accounts = accountSearch.FetchObjects();
//accounts now contains all CRM::Account objects that satisfy the above criteria.

If our search returns lots of objects, it may take some time to get the results back. If not all of the object's fields are need for the given task, we can pass a comma separated string with the field names to the RangerMSP.ObjectQuery.FetchObjects and the objects in the results will have only those fields populated.

CRM::ObjectQuery<CRM::Account> accountSearch(CRM::linkOR);
accountSearch.AddCriteria(CRM::Account::Fields.City, CRM::opEqual, "New York");
accountSearch.AddCriteria(CRM::Account::Fields.City, CRM::opEqual, "Chicago");
CRM::ObjectQuery<CRM::Account>::COLLECTION accounts = accountSearch.FetchObjects(CRM::Account::Fields::AccountREC_ID::Key() + "," + CRM::Account::Fields::City::Key());
//accounts now contains all CRM::Account objects that satisfy the above criteria.

The table below explains the important methods of the CRM::ObjectQuery class:

Access modifier Return value Method Arguments Description
public void AddCriteria (const std::string& string sField, OperatorEnum opEnum, const std::string& sValue) Adds one criteria to the initialized CRM::ObjectQuery object instance.

First parameter is the internal field name (column API Field name in the Object derived classes tables), second parameter is the criteria operator (see the table below) and third parameter is the value to search for. This variation of the AddCriteria method should be used only when searching in a field whose name is not included in the predefined fields.

public void AddCriteria (const CrmField& field, OperatorEnum opEnum, const std::string& sValue) Adds one criteria to the initialized CRM::ObjectQuery object instance.

First parameter is one of the CRM::CrmField preinitialized objects included in Fields class in each of the CRM::Object derived classes, second parameter is the criteria operator (see the table below) and third parameter is the value (std::string) to search for. This variation (or the one variations with the SYSTEMTIME or double as third parameter) of the AddCriteria method is the preferred way of adding criteria, unless there is no preinitialized CRM::CrmField object for the field.

public void AddCriteria (CrmField& field, OperatorEnum opEnum, const SYSTEMTIME& dtValue) Adds one criteria to the initialized CRM::ObjectQuery object instance.

First parameter is one of the CRM::CrmField preinitialized objects included in Fields class in each of the CRM::Object derived classes, second parameter is the criteria operator (see the table below) and third parameter is the value (SYSTEMTIME) to search for. Use this variation to search in fields that are of SYSTEMTIME type.

public void AddCriteria (CrmField& field, OperatorEnum opEnum, int nValue) Adds one criteria to the initialized CRM::ObjectQuery object instance.

First parameter is one of the CRM::CrmField preinitialized objects included in Fields class in each of the CRM::Object derived classes, second parameter is the criteria operator (see the table below) and third parameter is the value (int) to search for. Use this variation to search in fields that are of int type.

public void AddCriteria (CrmField& field, OperatorEnum opEnum, double nValue) Adds one criteria to the initialized CRM::ObjectQuery object instance.

First parameter is one of the CRM::CrmField preinitialized objects included in Fields class in each of the CRM::Object derived classes, second parameter is the criteria operator (see the table below) and third parameter is the value (double) to search for. Use this variation to search in fields that are of double type.

public void AddSortExpression (const std::string& sField, SortDirectionEnum sortEnum) Adds a sort expression to the initialized CRM::ObjectQuery object instance.

First parameter is the internal field name (column API Field name in the Object derived classes tables), second parameter is CRM::SortDirectionEnum (sortASC or sortDESC).

public void AddSortExpression (const CrmField& field, SortDirectionEnum sortEnum) Adds a sort expression to the initialized CRM::ObjectQuery object instance.

First parameter is one of the CRM::CrmField preinitialized objects included in Fields class in each of the CRM::Object derived classes, second parameter is CRM::SortDirectionEnum (sortASC or sortDESC).

public std::vector<OBJECT> FetchObjects () Executes the constructed query and returns a list of objects (of type OBJECT where OBJECT is any of the CRM::Object derived classes) that satisfies the criteria.

Below is the table with the available operators (CRM::OperatorEnum) used in the AddCriteria methods.

Enum value Description
CRM::OperatorEnum::opEqual Searches for objects using the exact match (equals) operator
CRM::OperatorEnum::opGreaterThan Searches for objects whose value is greater than the value passed in the third parameter in AddCriteria method.
CRM::OperatorEnum::opGreaterThanOrEqual Searches for objects whose value is greater or equal than the value passed in the third parameter in AddCriteria method.
CRM::OperatorEnum::opLessThan Searches for objects whose value is less than the value passed in the third parameter in AddCriteria method.
CRM::OperatorEnum::opLessThanOrEqual Searches for objects whose value is less than or equal the value passed in the third parameter in AddCriteria method.
CRM::OperatorEnum::opLike Combined with % (percent sign) in the value passed in the third parameter in AddCriteria method can be used for search with broader match.
CRM::OperatorEnum::opNot Searches for objects whose value differs from the one passed in the third parameter in AddCriteria method.
CRM::OperatorEnum::opNotLike

Field length limitations

Most of the database fields (analogous the properties mapped to these fields) have limits on data length that can be accepted. If more than the allowed length is assigned to a field, data is truncated to the length the field is capable of holding and the rest is discarded. Depending on the CRM::Config::RaiseExceptionIfDatabaseFieldTruncated setting (true/false), the operation could raise an exception alerting you that not all of the data was accepted. By default this setting is off (false) resulting in silent truncation of the extra data. Set the CRM::Config::RaiseExceptionIfDatabaseFieldTruncated to true if this behavior is not acceptable.

Below is an example of how to switch this setting ON:

RangerMSP.Config config;
config.AppName = "C++ Demo";
config.DllFolder = "C:\\RangerMSP\\ThirdParty\\UserDev";
config.DbFolder = "C:\\RangerMSP\\db";
config.RaiseExceptionIfDatabaseFieldTruncated = true;//the setting is ON now

//Initialize the CRM::Application
CRM::Application::Initialize(config);

CRM::Account account;
account.FileAs("ACME Company");
account.Dear("Mr.");
account.Contact("John Doe");
//the following line of code will throw an exception because we try to assign more than 40 chars to AddressLine1
account.AddressLine1("More than forty characters of the main address line");//Exception is thrown here
account.Save();

See Also