VB.NET API: Difference between revisions

From RangerMSP Wiki - PSA software for MSPs and IT services providers
Jump to navigation Jump to search
No edit summary
 
(125 intermediate revisions by 4 users not shown)
Line 2: Line 2:
= Disclaimer =
= Disclaimer =


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


= Introduction =
= Introduction =


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


<br>
<br>
Line 13: Line 14:
= System Requirements =
= System Requirements =


* CommitCRM 5.6 or later.
* RangerMSP 5.6 or later.
* Visual Basic .NET 2008 or Visual Basic .NET 2010.
* Visual Basic .NET 2008 or Visual Basic .NET 2010.
* CommitLib.dll (the CommitCRM VB.NET compiled library).
* CRMLib.dll (the RangerMSP VB.NET compiled library).


= Getting Started =
= Getting Started =


After you create your VB.NET project, you'll need to add a reference to the '''CommitLib.dll''' file, in order to have access to the CommitCRM library classes.
==Libraries Setup==
To download, compile and setup the libraries, please refer to [[VB.NET API Library Setup]].
 
==Start Basic Program==
After you create your VB.NET project, you'll need to add a reference to the '''CRMLib.dll''' 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:
# Using a Local Server - run your program on the same server where the RangerMSP Server runs.
# 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:


Each application using the library will have to initialize on startup the '''CommitCRM.Application''' object and terminate it on exit.
===Local Server===
Initialization method requires that you pass an object instance of '''CommitCRM.Config''' class configured with the following settings:
For connections to a local RangerMSP server configure the following settings:
   
   
* '''AppName'''
* '''AppName'''
: This is free text, preferably the name of your application.
: This is free text, preferably the name of your application.
 
 
* '''CommitDllFolder'''
* '''DllFolder'''
: Behind the scenes the library uses the two CommitCRM API dlls: '''CmtDbEng.dll''' and '''CmtDbQry.dll'''.  
: Behind the scenes the library uses the two RangerMSP API dlls: '''CmtDbEng.dll''' and '''CmtDbQry.dll'''.  
: In the default CommitCRM installation you'll find these files in <span style="color: #963A46;">'C:\Commit\ThirdParty\UserDev'</span>.
: In the default RangerMSP installation you'll find these files in <span style="color: #963A46;">'C:\RangerMSP\ThirdParty\UserDev'</span>.
: '''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.
: '''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.
   
   
* '''CommitDbFolder'''
* '''DbFolder'''
: Path to the CommitCRM database, default is <span style="color: #963A46;">'C:\Commit\db'</span>.
: Path to the RangerMSP database, default is <span style="color: #963A46;">'C:\RangerMSP\db'</span>.
   
   
Assuming these default values, we can configure the '''CommitCRM.Config''' object like this:
Assuming these default values, we can configure the '''CRM.Config''' object like this:
<font face="courier new" size="3">
<font face="courier new" size="3">
   
   
  <span style="color: #3A3AFF;">Dim</span> config <span style="color: #3A3AFF;">As New</span> CommitCRM.Config
  <span style="color: #3A3AFF;">Dim</span> config <span style="color: #3A3AFF;">As New</span> CRM.Config
  config.AppName = <span style="color: #963A46;">"VB.NET Demo"</span>
  config.AppName = <span style="color: #963A46;">"VB.NET Demo"</span>
  config.CommitDllFolder = <span style="color: #963A46;">"C:\Commit\ThirdParty\UserDev"</span>
  config.DllFolder = <span style="color: #963A46;">"C:\RangerMSP\ThirdParty\UserDev"</span>
  config.CommitDbFolder = <span style="color: #963A46;">"C:\Commit\db"</span>
  config.DbFolder = <span style="color: #963A46;">"C:\RangerMSP\db"</span>
</font>
</font>
   
   
You should of course check where these paths are exactly on your disk and modify these values accordingly.
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. <br>Url '''must include''' the http:// or https:// prefix, otherwise the API will not be able to connect.<br>Valid examples include http://localhost:4964/ and https://webapi.mycrmserver.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:
<font face="courier new" size="3">
   
   
Now we can initialize the '''CommitCRM.Application''' object with these settings:
<span style="color: #3A3AFF;">Dim</span> config <span style="color: #3A3AFF;">As New</span> CRM.Config
config.AppName = <span style="color: #963A46;">"VB.NET Demo"</span>
config.WebAPIUrl = <span style="color: #963A46;">"http://localhost:4964/"</span>
config.Password = <span style="color: #963A46;">"yourpassword"</span>
config.UseWebAPI = <span style="color: #3A3AFF;">True</span>
</font>
 
===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:
   
   
<font face="courier new" size="3">
<font face="courier new" size="3">
  CommitCRM.Application.Initialize(config)
  <span style="color: #66AD3A;">'CRM.Application.Initialize must be the first call before invoking any other RangerMSP library method
'and it should be done <span style="color: #963A46;">only once</span> in the program's lifetime.</span>
CRM.Application.Initialize(config)
</font>
</font>
   
   
If anything goes wrong, the above line will throw an exception of the '''CommitCRM.Exception''' class.  
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 CommitCRM library enclosed in a '''Try/Catch''' block.
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 '''CommitCRM.Application''' object:
Before exit, we terminate the '''CRM.Application''' object:
   
   
<font face="courier new" size="3">
<font face="courier new" size="3">
  CommitCRM.Application.Terminate()
  <span style="color: #66AD3A;">'Before exit we should call CRM.Application.Terminate to gracefully release all application resources
'and this should be done <span style="color: #963A46;">only once</span> in the program's lifetime.</span>
CRM.Application.Terminate()
</font>
</font>
 
The most basic VB.NET application that just connects to CommitCRM and terminates could look something like this:
The most basic VB.NET application that just connects to RangerMSP and terminates could look something like this:
   
   
<font face="courier new" size="3">
<font face="courier new" size="3">
  <span style="color: #3A3AFF;">Try</span>
  <span style="color: #3A3AFF;">Try</span>
     <span style="color: #3A3AFF;">Dim</span> config <span style="color: #3A3AFF;">As New</span> CommitCRM.Config
     <span style="color: #3A3AFF;">Dim</span> config <span style="color: #3A3AFF;">As New</span> CRM.Config
     config.AppName = <span style="color: #963A46;">"VB.NET Demo"</span>
     config.AppName = <span style="color: #963A46;">"VB.NET Demo"</span>
     config.CommitDllFolder = <span style="color: #963A46;">"C:\Commit\ThirdParty\UserDev"</span>
     config.DllFolder = <span style="color: #963A46;">"C:\RangerMSP\ThirdParty\UserDev"</span>
     config.CommitDbFolder = <span style="color: #963A46;">"C:\Commit\db"</span>
     config.DbFolder = <span style="color: #963A46;">"C:\RangerMSP\db"</span>
   
   
     CommitCRM.Application.Initialize(config)
     CRM.Application.Initialize(config)
   
   
     <span style="color: #66AD3A;">'At this point we have successfully initialized the CommitCRM.Application
     <span style="color: #66AD3A;">'At this point we have successfully initialized the CRM.Application
     'and can start using the other library classes</span>
     'and can start using the other library classes</span>
  <span style="color: #3A3AFF;">Catch</span> ex <span style="color: #3A3AFF;">As</span> Exception  
  <span style="color: #3A3AFF;">Catch</span> ex <span style="color: #3A3AFF;">As</span> Exception  
     Console.Out.Write(ex.Message)
     Console.Out.Write(ex.Message)
  <span style="color: #3A3AFF;">Finally</span>
  <span style="color: #3A3AFF;">Finally</span>
     CommitCRM.Application.Terminate()
     CRM.Application.Terminate()
  <span style="color: #3A3AFF;">End Try</span>
  <span style="color: #3A3AFF;">End Try</span>
</font>
</font>
Now that we have confirmed the connectivity to the RangerMSP server (if the above code successfully runs),
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.
we can continue adding more functionality to the example.
   
   
The library exposes as VB.NET classes the same CommitCRM objects (Account, Ticket etc.) available through the native CommitCRM API and you can refer to the  
The library exposes as VB.NET classes the same RangerMSP objects (Account, Ticket etc.) available through the native RangerMSP API and you can refer to the  
[[API_Reference_Manual#Database_Field_Listing|API Reference Manual]] for database fields reference.
[[API_Reference_Manual#Database_Field_Listing|API Reference Manual]] for database fields reference.
   
   
Line 90: Line 135:
With any of these objects you can:
With any of these objects you can:
   
   
* Search and query for objects with '''CommitCRM.ObjectQuery''' that satisfy certain criteria.
* Search and query for objects with '''CRM.ObjectQuery''' that satisfy certain criteria.
* Read and display the properties of the retrieved objects.
* Read and display the properties of the retrieved objects.
* Update and save the properties of the retrieved objects.
* Update and save the properties of the retrieved objects.
Line 96: Line 141:
   
   
   
   
Now let's see how we can search for '''CommitCRM.Account''' objects.
Now let's see how we can search for '''CRM.Account''' objects.
We instantiate an object of the '''CommitCRM.ObjectQuery''' class and pass '''CommitCRM.Account''' class as generics parameter.
We instantiate an object of the '''CRM.ObjectQuery''' class and pass '''CRM.Account''' class as generics parameter.
<font face="courier new" size="3">
<font face="courier new" size="3">
   
   
  <span style="color: #3A3AFF;">Dim</span> accountSearch <span style="color: #3A3AFF;">As New</span> CommitCRM.ObjectQuery(<span style="color: #3A3AFF;">Of</span> CommitCRM.Account)
  <span style="color: #3A3AFF;">Dim</span> accountSearch <span style="color: #3A3AFF;">As New</span> CRM.ObjectQuery(<span style="color: #3A3AFF;">Of</span> CRM.Account)
</font>
</font>
   
   
'''CommitCRM.ObjectQuery''' class can accept any of the CommitCRM objects in this parameter, but we want to search for accounts now.
'''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:
Next, we need to set criteria (or more than one) we want to search for:
<font face="courier new" size="3">
<font face="courier new" size="3">
  accountSearch.AddCriteria(<span style="color: #963A46;">"FLDCRDCITY"</span>, CommitCRM.OperatorEnum.opEqual, <span style="color: #963A46;">"New York"</span>)
  accountSearch.AddCriteria(CRM.Ticket.Fields.City, CRM.OperatorEnum.opEqual, <span style="color: #963A46;">"New York"</span>)
</font>
</font>
   
   
The first parameter to the '''AddCriteria''' method is the field name we want to look in. Refer to [[API_Reference_Manual#Account_Fields|Account_Fields]]  
The first parameter to the '''AddCriteria''' method is either a Shared 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 [[VB.NET_API#Account_Class|Account Class]]  
for a complete list of the available fields for the '''CommitCRM.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 '''CommitCRM.OperatorEnum.opEqual''' to get only exact matches.
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 '''CommitCRM.OperatorEnum.opLike''' operator.
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 '''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 '''CRM.OperatorEnum.opLike''' operator,  
will match the phrase even if in the middle of a sentence.
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):
Now we can execute the search and retrieve the '''CRM.Account''' objects (if any):
   
   
<font face="courier new" size="3">
<font face="courier new" size="3">
  <span style="color: #3A3AFF;">Dim</span> accounts <span style="color: #3A3AFF;">As</span> List(<span style="color: #3A3AFF;">Of</span> CommitCRM.Account) = accountSearch.FetchObjects()
  <span style="color: #3A3AFF;">Dim</span> accounts <span style="color: #3A3AFF;">As</span> List(<span style="color: #3A3AFF;">Of</span> CRM.Account) = accountSearch.FetchObjects()
</font>
</font>
   
   
The above line will populate the List ('''System.Collections.Generic.List''') with all '''CommitCRM.Account''' objects that were found.
The above line will populate the List ('''System.Collections.Generic.List''') with all '''CRM.Account''' objects that were found.
Now we can use '''For Each - Next''' statement to iterate through the accounts:
Now we can use '''For Each - Next''' statement to iterate through the accounts:
   
   
<font face="courier new" size="3">
<font face="courier new" size="3">
  <span style="color: #3A3AFF;">For Each</span> account <span style="color: #3A3AFF;">In</span> accounts
  <span style="color: #3A3AFF;">For Each</span> account <span style="color: #3A3AFF;">In</span> accounts
     Console.Out.Write(account.CompanyName + vbCrLf)
     Console.Out.WriteLine(account.CompanyName)
  <span style="color: #3A3AFF;">Next</span>
  <span style="color: #3A3AFF;">Next</span>
</font>
</font>
Line 145: Line 191:
</font>
</font>
   
   
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.
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 CommitCRM objects.
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 options is to add a new ticket for each of the accounts:
Another option is to add a new ticket for each of the accounts:
   
   
<font face="courier new" size="3">
<font face="courier new" size="3">
  <span style="color: #3A3AFF;">For Each</span> account <span style="color: #3A3AFF;">In</span> accounts
  <span style="color: #3A3AFF;">For Each</span> account <span style="color: #3A3AFF;">In</span> accounts
     <span style="color: #3A3AFF;">Dim</span> ticket <span style="color: #3A3AFF;">As New</span> CommitCRM.Ticket
     <span style="color: #3A3AFF;">Dim</span> ticket <span style="color: #3A3AFF;">As New</span> CRM.Ticket
     ticket.AccountREC_ID = account.AccountREC_ID
     ticket.AccountREC_ID = account.AccountREC_ID
     ticket.Description = <span style="color: #963A46;">"Sample ticket for a NewYork account"</span>
     ticket.Description = <span style="color: #963A46;">"Sample ticket for a NewYork account"</span>
Line 158: Line 204:
  <span style="color: #3A3AFF;">Next</span>
  <span style="color: #3A3AFF;">Next</span>
</font>
</font>
 
Each of the CommitCRM library objects have a set of properties that are exposed as VB.NET properties that you can directly manipulate or read from.
= GetFieldValue and SetFieldValue methods =
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.
Each of the RangerMSP library objects have a set of properties that are exposed as VB.NET 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 RangerMSP fields.
 
<br>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:
Here is an equivalent of the above example that uses these two generic methods, instead of the object's properties:
Line 167: Line 216:
<font face="courier new" size="3">
<font face="courier new" size="3">
  <span style="color: #3A3AFF;">For Each</span> account <span style="color: #3A3AFF;">In</span> accounts
  <span style="color: #3A3AFF;">For Each</span> account <span style="color: #3A3AFF;">In</span> accounts
     <span style="color: #3A3AFF;">Dim</span> ticket <span style="color: #3A3AFF;">As New</span> CommitCRM.Ticket
     <span style="color: #3A3AFF;">Dim</span> ticket <span style="color: #3A3AFF;">As New</span> CRM.Ticket
     ticket.SetFieldValue(<span style="color: #963A46;">"FLDTKTCARDID"</span>, account.GetFieldValue(<span style="color: #963A46;">"FLDCRDRECID"</span>))
     ticket.SetFieldValue(<span style="color: #963A46;">"FLDTKTCARDID"</span>, account.GetFieldValue(<span style="color: #963A46;">"FLDCRDRECID"</span>))
     ticket.SetFieldValue(<span style="color: #963A46;">"FLDTKTPROBLEM"</span>, <span style="color: #963A46;">"Sample ticket for a NewYork account"</span>)
     ticket.SetFieldValue(<span style="color: #963A46;">"FLDTKTPROBLEM"</span>, <span style="color: #963A46;">"Sample ticket for a NewYork account"</span>)
Line 173: Line 222:
  <span style="color: #3A3AFF;">Next</span>
  <span style="color: #3A3AFF;">Next</span>
</font>
</font>
All internal field names are listed in [[VB.NET_API#Classes_and_Objects|Classes and Objects]] below.


= Exception Handling =
= Exception Handling =
   
   
While working with the CommitCRM VB.NET library, some operations can fail. In this case the library will throw an exception of the '''CommitCRM.Exception''' class.
While working with the RangerMSP VB.NET 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 CommitCRM library in a '''Try/Catch''' block.
We recommend enclosing all calls to the RangerMSP 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,
To find out more about the exact error that ocured when an exception is thrown, you can inspect the '''CRM.Exception.Status''' property that holds the last RangerMSP '''Status''' value,
or inspect the list of '''CommitCRM.Exception.Codes''' (if any). Please refer to [[API_Reference_Manual#Error_Codes_Description|Error Codes Description]] for the description of these values.
or inspect the list of '''CRM.Exception.Codes''' (if any). Please refer to [[API_Reference_Manual#Error_Codes_Description|Error Codes Description]] for the description of these values.


= Complete Program Sample =
= Complete Program Sample =
Line 190: Line 241:
   
   
         <span style="color: #3A3AFF;">Try</span>
         <span style="color: #3A3AFF;">Try</span>
             <span style="color: #66AD3A;">'Setup the CommitCRM.Config object</span>
             <span style="color: #66AD3A;">'Setup the CRM.Config object</span>
             <span style="color: #3A3AFF;">Dim</span> config <span style="color: #3A3AFF;">As New</span> CommitCRM.Config
             <span style="color: #3A3AFF;">Dim</span> config <span style="color: #3A3AFF;">As New</span> CRM.Config
             config.AppName = <span style="color: #963A46;">"VB.NET Demo"</span>
             config.AppName = <span style="color: #963A46;">"VB.NET Demo"</span>
             config.CommitDllFolder = <span style="color: #963A46;">"C:\Commit\ThirdParty\UserDev"</span>
             config.DllFolder = <span style="color: #963A46;">"C:\RangerMSP\ThirdParty\UserDev"</span>
             config.CommitDbFolder = <span style="color: #963A46;">"C:\Commit\db"</span>
             config.DbFolder = <span style="color: #963A46;">"C:\RangerMSP\db"</span>
   
   
             <span style="color: #66AD3A;">'Initialize the CommitCRM.Application</span>
             <span style="color: #66AD3A;">'Initialize the CRM.Application</span>
             CommitCRM.Application.Initialize(config)
             CRM.Application.Initialize(config)
   
   
             <span style="color: #66AD3A;">'At this point we have successfully initialized the CommitCRM.Application
             <span style="color: #66AD3A;">'At this point we have successfully initialized the CRM.Application
             'and can start using the other library classes</span>
             'and can start using the other library classes</span>
   
   
             <span style="color: #66AD3A;">'search for "New York" in the FLDCRDCITY field</span>
             <span style="color: #66AD3A;">'search for "New York" in the FLDCRDCITY field</span>
             <span style="color: #3A3AFF;">Dim</span> accountSearch <span style="color: #3A3AFF;">As New</span> CommitCRM.ObjectQuery(<span style="color: #3A3AFF;">Of</span> CommitCRM.Account)
             <span style="color: #3A3AFF;">Dim</span> accountSearch <span style="color: #3A3AFF;">As New</span> CRM.ObjectQuery(<span style="color: #3A3AFF;">Of</span> CRM.Account)
             accountSearch.AddCriteria(<span style="color: #963A46;">"FLDCRDCITY"</span>, CommitCRM.OperatorEnum.opEqual, <span style="color: #963A46;">"New York"</span>)
             accountSearch.AddCriteria(<span style="color: #963A46;">"FLDCRDCITY"</span>, CRM.OperatorEnum.opEqual, <span style="color: #963A46;">"New York"</span>)
             <span style="color: #3A3AFF;">Dim</span> accounts <span style="color: #3A3AFF;">As</span> List(<span style="color: #3A3AFF;">Of</span> CommitCRM.Account) = accountSearch.FetchObjects()
             <span style="color: #3A3AFF;">Dim</span> accounts <span style="color: #3A3AFF;">As</span> List(<span style="color: #3A3AFF;">Of</span> CRM.Account) = accountSearch.FetchObjects()
   
   
             <span style="color: #66AD3A;">'loop through the retrieved accounts and output the CompanyName</span>
             <span style="color: #66AD3A;">'loop through the retrieved accounts and output the CompanyName</span>
             <span style="color: #3A3AFF;">For Each</span> account <span style="color: #3A3AFF;">In</span> accounts
             <span style="color: #3A3AFF;">For Each</span> account <span style="color: #3A3AFF;">In</span> accounts
                 Console.Out.Write(account.CompanyName + vbCrLf)
                 Console.Out.WriteLine(account.CompanyName)
             <span style="color: #3A3AFF;">Next</span>
             <span style="color: #3A3AFF;">Next</span>
   
   
         <span style="color: #3A3AFF;">Catch</span> ex <span style="color: #3A3AFF;">As</span> CommitCRM.Exception <span style="color: #66AD3A;">'here we catch commit specific error
         <span style="color: #3A3AFF;">Catch</span> ex <span style="color: #3A3AFF;">As</span> CRM.Exception <span style="color: #66AD3A;">'here we catch RangerMSP specific error
             'we can inspect the Commit status (exc.Status)  
             'we can inspect the RangerMSP status (exc.Status)  
             'exc.Codes contains all error codes last call generated
             'exc.Codes contains all error codes last call generated
   
   
Line 222: Line 273:
             Console.Out.Write(ex.Message)
             Console.Out.Write(ex.Message)
         <span style="color: #3A3AFF;">Finally</span>
         <span style="color: #3A3AFF;">Finally</span>
             CommitCRM.Application.Terminate()
             CRM.Application.Terminate()
         <span style="color: #3A3AFF;">End Try</span>
         <span style="color: #3A3AFF;">End Try</span>
     <span style="color: #3A3AFF;">End Sub</span>
     <span style="color: #3A3AFF;">End Sub</span>
Line 229: Line 280:
</font>
</font>


= Object Class =
= Classes and Objects =
The RangerMSP VB.NET 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:
# API functions and routines (which are derived from the base '''CRM.Object''' class).
# Class data fields, providing an easy way to update the object's data.
 
<br>
All RangerMSP'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 CRM.Application was initialized successfully), one would use the following code snippet:


The '''CommitCRM.Object''' class is the base class for all CommitCRM accessible objects (as Ticket, Account, Asset, etc.). The public routines and functions exposed by the CommitCRM.Object class are available to the derived classes.
<font face="courier new" size="3">
<span style="color: #3A3AFF;">Dim</span> account <span style="color: #3A3AFF;">As New</span> CRM.Account
account.FileAs = <span style="color: #963A46;">"ACME Company"</span>
account.Dear = <span style="color: #963A46;">"Mr."</span>
account.Contact = <span style="color: #963A46;">"John Doe"</span>
account.Save()
</font>
<br>
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 Method Reference Table ==
<br>
== Object Class ==


The '''CRM.Object''' class is the base class for all RangerMSP accessible objects (as Ticket, Account, Asset, etc.). The public routines and functions exposed by the CRM.Object class are available to the derived classes.
<br><br>
'''Object Method Reference Table'''
{| class="wikitable"
{| class="wikitable"
|-
|-
Line 247: Line 318:
| (sKey As String, sValue As String)
| (sKey As String, sValue As String)
|  
|  
| Assigns the value ('''sValue''') of the field passed in '''sKey''' argument. '''Save''' must be called for the change to take effect.
| 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 Function
| Public Function
Line 253: Line 324:
| (sKey As String)
| (sKey As String)
| As String
| As String
| Retrieves the value of the field passed in '''sKey''' argument.
| Retrieves the value of the field passed in '''sKey''' argument. Use this method to access user-defined custom fields.
|-
|-
| Public Sub
| Public Sub
Line 274: Line 345:
|}
|}


= Account Class =
== 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 '''CommitCRM.Account''' class derives from '''CommitCRM.Object''' and encapsulates the [[API_Reference_Manual#Account_Fields|Account_Fields]].
The '''CRM.Account''' class derives from '''CRM.Object''' and encapsulates the [[API_Reference_Manual#Account_Fields|Account Fields]].
The following table lists all exposed '''CommitCRM.Account''' properties.
The following table lists all exposed '''CRM.Account''' properties.


'''Account Properties Reference Table'''
{| class="wikitable"
{| class="wikitable"
|-
|-
Line 285: Line 361:
! '''API Field Name'''
! '''API Field Name'''
! '''Return value'''
! '''Return value'''
! '''Field length'''
|-
|-
| Public ReadOnly Property
| Public ReadOnly Property
Line 290: Line 367:
| FLDCRDRECID
| FLDCRDRECID
| As String
| As String
| 20
|-
|-
| Public Property
| Public Property
Line 295: Line 373:
| FLDCRDASSIGNCARDID
| FLDCRDASSIGNCARDID
| As String
| As String
| 20
|-
|-
| Public Property
| Public Property
Line 300: Line 379:
| FLDCRDCOMPANY
| FLDCRDCOMPANY
| As String
| As String
| 60
|-
|-
| Public Property
| Public Property
Line 305: Line 385:
| FLDCRDCONTACT
| FLDCRDCONTACT
| As String
| As String
| 40
|-
| Public ReadOnly Property
| '''Status'''
| FLDCRDSUBCONTSTATUS
| As String
| 1
|-
|-
| Public Property
| Public Property
Line 310: Line 397:
| FLDCRDASSISTANT
| FLDCRDASSISTANT
| As String
| As String
| 20
|-
|-
| Public Property
| Public Property
Line 315: Line 403:
| FLDCRDBCRECID
| FLDCRDBCRECID
| As String
| As String
| 20
|-
|-
| Public Property
| Public Property
Line 320: Line 409:
| FLDCRDCARDID2
| FLDCRDCARDID2
| As String
| As String
| 15
|-
|-
| Public Property
| Public Property
Line 325: Line 415:
| FLDCRDCARDID3
| FLDCRDCARDID3
| As String
| As String
| 15
|-
|-
| Public Property
| Public Property
Line 330: Line 421:
| FLDCRDCARDMESSAGE
| FLDCRDCARDMESSAGE
| As String
| As String
| Unlimited
|-
|-
| Public Property
| Public Property
Line 335: Line 427:
| FLDCRDADDRESS1
| FLDCRDADDRESS1
| As String
| As String
| 40
|-
|-
| Public Property
| Public Property
Line 340: Line 433:
| FLDCRDADDRESS2
| FLDCRDADDRESS2
| As String
| As String
| 40
|-
|-
| Public Property
| Public Property
Line 345: Line 439:
| FLDCRDADDRESS3
| FLDCRDADDRESS3
| As String
| As String
| 40
|-
|-
| Public Property
| Public Property
Line 350: Line 445:
| FLDCRDCITY
| FLDCRDCITY
| As String
| As String
| 30
|-
|-
| Public Property
| Public Property
| '''Country'''
| '''Country'''
| FLDCRDSTATE
| FLDCRDCOUNTRY
| As String
| As String
| 20
|-
|-
| Public Property
| Public Property
| '''State'''
| '''State'''
| FLDCRDCOUNTRY
| FLDCRDSTATE
| As String
| As String
| 30
|-
|-
| Public Property
| Public Property
Line 365: Line 463:
| FLDCRDZIP
| FLDCRDZIP
| As String
| As String
| 15
|-
|-
| Public Property
| Public Property
| '''CreationDate'''
| '''CreationDate'''
| FLDCRDCREATEDATE
| FLDCRDCREATEDATE
| As String
| As DateTime
| N/A
|-
|-
| Public Property
| Public Property
Line 375: Line 475:
| FLDCRDCREATEUSERID
| FLDCRDCREATEUSERID
| As String
| As String
| 20
|-
|-
| Public Property
| Public Property
Line 380: Line 481:
| FLDCRDDEAR
| FLDCRDDEAR
| As String
| As String
| 20
|-
|-
| Public Property
| Public Property
Line 385: Line 487:
| FLDCRDDEPARTMENT
| FLDCRDDEPARTMENT
| As String
| As String
| 35
|-
|-
| Public Property
| Public Property
Line 390: Line 493:
| FLDCRDDOCSFOLDER
| FLDCRDDOCSFOLDER
| As String
| As String
| 100
|-
|-
| Public Property
| Public Property
Line 395: Line 499:
| FLDCRDEMAIL1
| FLDCRDEMAIL1
| As String
| As String
| 70
|-
|-
| Public Property
| Public Property
Line 400: Line 505:
| FLDCRDEMAIL2
| FLDCRDEMAIL2
| As String
| As String
| 70
|-
|-
| Public Property
| Public Property
| '''AccountType'''
| '''AccountType'''
| FLDCRDENTITYKIND
| FLDCRDENTITYKIND
| As String
| As Integer
| N/A
|-
|-
| Public Property
| Public Property
Line 410: Line 517:
| FLDCRDFAX1
| FLDCRDFAX1
| As String
| As String
| 25
|-
|-
| Public Property
| Public Property
Line 415: Line 523:
| FLDCRDFAXDESC1
| FLDCRDFAXDESC1
| As String
| As String
| 15
|-
|-
| Public Property
| Public Property
Line 420: Line 529:
| FLDCRDFULLNAME
| FLDCRDFULLNAME
| As String
| As String
| 60
|-
|-
| Public Property
| Public Property
Line 425: Line 535:
| FLDCRDKIND
| FLDCRDKIND
| As String
| As String
| 30
|-
|-
| Public Property
| Public Property
Line 430: Line 541:
| FLDCRDLASTNAME
| FLDCRDLASTNAME
| As String
| As String
| 20
|-
|-
| Public Property
| Public Property
Line 435: Line 547:
| FLDCRDNOTES
| FLDCRDNOTES
| As String
| As String
| Unlimited
|-
|-
| Public Property
| Public Property
Line 440: Line 553:
| FLDCRDPERSONID
| FLDCRDPERSONID
| As String
| As String
| 20
|-
|-
| Public Property
| Public Property
Line 445: Line 559:
| FLDCRDPHNDESC1
| FLDCRDPHNDESC1
| As String
| As String
| 40
|-
|-
| Public Property
| Public Property
Line 450: Line 565:
| FLDCRDPHNDESC2
| FLDCRDPHNDESC2
| As String
| As String
| 40
|-
|-
| Public Property
| Public Property
Line 455: Line 571:
| FLDCRDPHNDESC3
| FLDCRDPHNDESC3
| As String
| As String
| 15
|-
|-
| Public Property
| Public Property
Line 460: Line 577:
| FLDCRDPHNDESC4
| FLDCRDPHNDESC4
| As String
| As String
| 15
|-
|-
| Public Property
| Public Property
Line 465: Line 583:
| FLDCRDPHONE1
| FLDCRDPHONE1
| As String
| As String
| 25
|-
|-
| Public Property
| Public Property
Line 470: Line 589:
| FLDCRDPHONE2
| FLDCRDPHONE2
| As String
| As String
| 25
|-
|-
| Public Property
| Public Property
Line 475: Line 595:
| FLDCRDPHONE3
| FLDCRDPHONE3
| As String
| As String
| 25
|-
|-
| Public Property
| Public Property
Line 480: Line 601:
| FLDCRDPHONE4
| FLDCRDPHONE4
| As String
| As String
| 25
|-
|-
| Public Property
| Public Property
Line 485: Line 607:
| FLDCRDREGIONCODE
| FLDCRDREGIONCODE
| As String
| As String
| 15
|-
|-
| Public Property
| Public Property
Line 490: Line 613:
| FLDCRDSHOWMESSAGE
| FLDCRDSHOWMESSAGE
| As String
| As String
| 1
|-
|-
| Public Property
| Public Property
Line 495: Line 619:
| FLDCRDSUBCODE
| FLDCRDSUBCODE
| As String
| As String
| 15
|-
|-
| Public Property
| Public Property
Line 500: Line 625:
| FLDCRDSUFFIX
| FLDCRDSUFFIX
| As String
| As String
| 20
|-
|-
| Public Property
| Public Property
Line 505: Line 631:
| FLDCRDTAXCODE1
| FLDCRDTAXCODE1
| As String
| As String
| 3
|-
|-
| Public Property
| Public Property
Line 510: Line 637:
| FLDCRDTAXCODE2
| FLDCRDTAXCODE2
| As String
| As String
| 3
|-
|-
| Public Property
| Public Property
Line 515: Line 643:
| FLDCRDTITLE
| FLDCRDTITLE
| As String
| As String
| 30
|-
|-
| Public Property
| Public Property
Line 520: Line 649:
| FLDCRDUPDATEUSERID
| FLDCRDUPDATEUSERID
| As String
| As String
| 20
|-
|-
| Public Property
| Public Property
Line 525: Line 655:
| FLDCRDURL1
| FLDCRDURL1
| As String
| As String
| 100
|-
|-
| Public Property
| Public Property
Line 530: Line 661:
| FLDCRDURL2
| FLDCRDURL2
| As String
| As String
| 100
|-
|-
| Public Property
| Public Property
Line 535: Line 667:
| FLDCRDUSER1
| FLDCRDUSER1
| As String
| As String
| 30
|-
|-
| Public Property
| Public Property
Line 540: Line 673:
| FLDCRDUSER2
| FLDCRDUSER2
| As String
| As String
| 30
|-
|-
| Public Property
| Public Property
Line 545: Line 679:
| FLDCRDUSER3
| FLDCRDUSER3
| As String
| As String
| 30
|-
|-
| Public Property
| Public Property
Line 550: Line 685:
| FLDCRDUSER4
| FLDCRDUSER4
| As String
| As String
| 30
|-
|-
| Public Property
| Public Property
Line 555: Line 691:
| FLDCRDUSER5
| FLDCRDUSER5
| As String
| As String
| 30
|}
=== Ticket Class ===
The '''CRM.Ticket''' class derives from '''CRM.Object''' and encapsulates the [[API_Reference_Manual#Ticket_Fields|Ticket Fields]].
The following table lists all exposed '''CRM.Ticket''' properties.
'''Ticket Properties Reference Table'''
{| class="wikitable"
|-
! '''Access modifier'''
! '''Property'''
! '''API Field Name'''
! '''Return value'''
! '''Field length'''
|-
| Public ReadOnly Property
| '''TicketREC_ID'''
| FLDTKTRECID
| As String
| 20
|-
| Public Property
| '''AccountREC_ID'''
| FLDTKTCARDID
| As String
| 20
|-
| Public Property
| '''AssetREC_ID'''
| FLDTKTASSETRECID
| As String
| 20
|-
| Public Property
| '''ContactREC_ID'''
| FLDTKTCONTACTID
| As String
| 20
|-
| Public Property
| '''ContractREC_ID'''
| FLDTKTBCRECID
| As String
| 20
|-
| Public Property
| '''EmployeeREC_ID'''
| FLDTKTWORKERID
| As String
| 20
|-
| Public Property
| '''TicketPriority'''
| FLDTKTPRIORITY
| As Integer
| N/A
|-
| Public Property
| '''TicketNumber'''
| FLDTKTTICKETNO
| As String
| 20
|-
| Public Property
| '''Description'''
| FLDTKTPROBLEM
| As String
| Unlimited
|-
| Public Property
| '''TicketType'''
| FLDTKTKIND
| As String
| 25
|-
| Public Property
| '''Source'''
| FLDTKTSOURCE
| As String
| 30
|-
| Public Property
| '''EstimatedDurationTime'''
| FLDTKTSCHEDLENESTIM
| As Integer
| N/A
|-
| Public Property
| '''ShowTicketInDispatcher'''
| FLDTKTFORDISPATCH
| As String
| 1
|-
| Public Property
| '''Status'''
| FLDTKTSTATUS
| As Integer
| N/A
|-
| Public Property
| '''CreatedByUser'''
| FLDTKTCREATEUSER
| As String
| 20
|-
| Public Property
| '''DueDate'''
| FLDTKTDUEDATETIME
| As DateTime
| N/A
|-
| Public Property
| '''Resolution'''
| FLDTKTSOLUTION
| As String
| Unlimited
|-
| Public ReadOnly Property
| '''UpdateDate'''
| FLDTKTUPDATEDATE
| As DateTime
| N/A
|}
=== Asset Class ===
The '''CRM.Asset''' class derives from '''CRM.Object''' and encapsulates the [[API_Reference_Manual#Asset_Fields|Asset Fields]].
The following table lists all exposed '''CRM.Asset''' properties.
'''Asset Properties Reference Table'''
{| class="wikitable"
|-
! '''Access modifier'''
! '''Property'''
! '''API Field Name'''
! '''Return value'''
! '''Field length'''
|-
| Public ReadOnly Property
| '''AssetREC_ID'''
| FLDASTRECID
| As String
| 20
|-
| Public Property
| '''AssetCode'''
| FLDASTASSETCODE
| As String
| 30
|-
| Public Property
| '''AssetType'''
| FLDASTASSETTYPE
| As String
| 1
|-
| Public Property
| '''AssetName'''
| FLDASTNAME
| As String
| 60
|-
| Public Property
| '''Status'''
| FLDASTSTATUS
| As String
| 1
|-
| Public Property
| '''SerialNo'''
| FLDASTSERIALNO
| As String
| 30
|-
| Public Property
| '''AccountREC_ID'''
| FLDASTACCRECID
| As String
| 20
|-
| Public Property
| '''ContactREC_ID'''
| FLDASTCONTACTRECID
| As String
| 20
|-
| Public Property
| '''CreatedByUser'''
| FLDASTCREATEUSER
| As String
| 20
|-
| Public Property
| '''PurchaseDate'''
| FLDASTCUSTPURDATE
| As DateTime
| N/A
|-
| Public Property
| '''PurchasedFromUs'''
| FLDASTCUSTPURFROMUS
| As String
| 1
|-
| Public Property
| '''PurchaseInvoice'''
| FLDASTCUSTPUROURINV
| As String
| 15
|-
| Public Property
| '''CustomerPO'''
| FLDASTCUSTPURPO
| As String
| 15
|-
| Public Property
| '''PurchasePrice'''
| FLDASTCUSTPURPRICE
| As Double
| N/A
|-
| Public Property
| '''DeliveredDate'''
| FLDASTDELIVEDATE
| As DateTime
| N/A
|-
| Public Property
| '''Description'''
| FLDASTDESC
| As String
| Unlimited
|-
| Public Property
| '''InstalledBy'''
| FLDASTINSTALBY
| As String
| 20
|-
| Public Property
| '''InstalledDate'''
| FLDASTINSTALDATE
| As DateTime
| N/A
|-
| Public Property
| '''LicenseCodes'''
| FLDASTLICENSECODE
| As String
| Unlimited
|-
| Public Property
| '''LicenseKeys'''
| FLDASTLICENSEKEYS
| As String
| Unlimited
|-
| Public Property
| '''LicenseNotes'''
| FLDASTLICENSENOTES
| As String
| Unlimited
|-
| Public Property
| '''Location'''
| FLDASTLOCATION
| As String
| 50
|-
| Public Property
| '''Manufacturer'''
| FLDASTMANUFACTURER
| As String
| 40
|-
| Public Property
| '''MnfSerialNo'''
| FLDASTMNFSERIALNO
| As String
| 30
|-
| Public Property
| '''Model'''
| FLDASTMODEL
| As String
| 20
|-
| Public Property
| '''Notes'''
| FLDASTNOTES
| As String
| Unlimited
|-
| Public Property
| '''Quantity'''
| FLDASTQUANTITY
| As Double
| N/A
|-
| Public Property
| '''LastUpdateBy'''
| FLDASTUPDATEUSER
| As String
| 20
|-
| Public Property
| '''Field1'''
| FLDASTUSER1
| As String
| 25
|-
| Public Property
| '''Field2'''
| FLDASTUSER2
| As String
| 25
|-
| Public Property
| '''Field3'''
| FLDASTUSER3
| As String
| 25
|-
| Public Property
| '''Field4'''
| FLDASTUSER4
| As String
| 25
|-
| Public Property
| '''Field5'''
| FLDASTUSER5
| As String
| 25
|-
| Public Property
| '''Date1'''
| FLDASTUSERDATE1
| As DateTime
| N/A
|-
| Public Property
| '''Number1'''
| FLDASTUSERNUMBER1
| As Double
| N/A
|-
| Public Property
| '''VendorPurchasedDate'''
| FLDASTVENDORDATEPURC
| As DateTime
| N/A
|-
| Public Property
| '''VendorInvoice'''
| FLDASTVENDORINVNO
| As String
| 15
|-
| Public Property
| '''VendorPO'''
| FLDASTVENDOROURPO
| As String
| 15
|-
| Public Property
| '''VendorPrice'''
| FLDASTVENDORPRICE
| As Double
| N/A
|-
| Public Property
| '''Vendor'''
| FLDASTVENDORRECID
| As String
| 20
|-
| Public Property
| '''VendorSerialNo'''
| FLDASTVENDORSERNO
| As String
| 30
|-
| Public Property
| '''VendorWarrantyExpDate'''
| FLDASTVENDORWARREXP
| As DateTime
| N/A
|-
| Public Property
| '''Version'''
| FLDASTVERSION
| As String
| 15
|-
| Public Property
| '''WarrantyLicenseExp'''
| FLDASTWARREXPDATE
| As DateTime
| N/A
|}
=== Calendar Class ===
The '''CRM.Calendar''' class derives from '''CRM.Object''' and encapsulates the [[API_Reference_Manual#Calendar_Fields|Calendar Fields]] of event type Appointment.
The following table lists all exposed '''CRM.Calendar''' properties.
'''Calendar Properties Reference Table'''
{| class="wikitable"
|-
! '''Access modifier'''
! '''Property'''
! '''API Field Name'''
! '''Return value'''
! '''Field length'''
|-
| Public ReadOnly Property
| '''CalendarREC_ID'''
| FLDEVTRECID
| As String
| 20
|-
| Public Property
| '''EventType'''
| FLDEVTWRITETOID
| As Integer
| N/A
|-
| Public Property
| '''EmployeeREC_ID'''
| FLDEVTWORKERID
| As String
| 20
|-
| Public Property
| '''PrivateUser'''
| FLDEVTPRIVATEID
| As String
| 20
|-
| Public Property
| '''AccountREC_ID'''
| FLDEVTCARDID
| As String
| 20
|-
| Public Property
| '''ContactREC_ID'''
| FLDEVTCONTACTID
| As String
| 20
|-
| Public Property
| '''DocumentREC_ID'''
| FLDEVTDOCID
| As String
| 20
|-
| Public Property
| '''DoneIndication'''
| FLDEVTDONE
| As Boolean
| N/A
|-
| Public Property
| '''[Date]'''
| FLDEVTEVENTDATE
| As DateTime
| N/A
|-
| Public Property
| '''Description'''
| FLDEVTFREETEXT
| As String
| Unlimited
|-
| Public Property
| '''TimeStart'''
| FLDEVTFROMTIME
| As String
| N/A
|-
| Public Property
| '''TimeEnd'''
| FLDEVTTOTIME
| As String
| N/A
|-
| Public Property
| '''RelLinkREC_ID'''
| FLDEVTLINKRECID
| As String
| 20
|-
| Public Property
| '''Field1'''
| FLDEVTFAMILY
| As String
| 50
|-
| Public Property
| '''Field2'''
| FLDEVTACTION
| As String
| 50
|-
| Public Property
| '''Field3'''
| FLDEVTPLACE
| As String
| 40
|-
| Public Property
| '''Field4'''
| FLDEVTPLACE1
| As String
| 30
|-
| Public Property
| '''Field5'''
| FLDEVTPLACE2
| As String
| 30
|-
| Public Property
| '''CreatedByUser'''
| FLDEVTCREATEUSERID
| As String
| 20
|-
| Public Property
| '''LastUpdateByUser'''
| FLDEVTUPDATEUSER
| As String
| 20
|}
=== Task Class ===
The '''CRM.Task''' class derives from '''CRM.Object''' and encapsulates the [[API_Reference_Manual#Calendar_Fields|Calendar Fields]] of event type Task.
The following table lists all exposed '''CRM.Task''' properties.
'''Task Properties Reference Table'''
{| class="wikitable"
|-
! '''Access modifier'''
! '''Property'''
! '''API Field Name'''
! '''Return value'''
! '''Field length'''
|-
| Public ReadOnly Property
| '''TaskREC_ID'''
| FLDEVTRECID
| As String
| 20
|-
| Public Property
| '''EventType'''
| FLDEVTWRITETOID
| As Integer
| N/A
|-
| Public Property
| '''EmployeeREC_ID'''
| FLDEVTWORKERID
| As String
| 20
|-
| Public Property
| '''PrivateUser'''
| FLDEVTPRIVATEID
| As String
| 20
|-
| Public Property
| '''AccountREC_ID'''
| FLDEVTCARDID
| As String
| 20
|-
| Public Property
| '''ContactREC_ID'''
| FLDEVTCONTACTID
| As String
| 20
|-
| Public Property
| '''DocumentREC_ID'''
| FLDEVTDOCID
| As String
| 20
|-
| Public Property
| '''DoneIndication'''
| FLDEVTDONE
| As Boolean
| N/A
|-
| Public Property
| '''[Date]'''
| FLDEVTEVENTDATE
| As DateTime
| N/A
|-
| Public Property
| '''Description'''
| FLDEVTFREETEXT
| As String
| Unlimited
|-
| Public Property
| '''TimeStart'''
| FLDEVTFROMTIME
| As String
| N/A
|-
| Public Property
| '''RelLinkREC_ID'''
| FLDEVTLINKRECID
| As String
| 20
|-
| Public Property
| '''Field1'''
| FLDEVTFAMILY
| As String
| 50
|-
| Public Property
| '''Field2'''
| FLDEVTACTION
| As String
| 50
|-
| Public Property
| '''Field3'''
| FLDEVTPLACE
| As String
| 40
|-
| Public Property
| '''Field4'''
| FLDEVTPLACE1
| As String
| 30
|-
| Public Property
| '''Field5'''
| FLDEVTPLACE2
| As String
| 30
|-
| Public Property
| '''CreatedByUser'''
| FLDEVTCREATEUSERID
| As String
| 20
|-
| Public Property
| '''LastUpdateByUser'''
| FLDEVTUPDATEUSER
| As String
| 20
|}
=== Charge Class ===
The '''CRM.Charge''' class derives from '''CRM.Object''' and encapsulates the [[API_Reference_Manual#Charge_Fields|Charge Fields]].
The following table lists all exposed '''CRM.Charge''' properties.
'''Charge Properties Reference Table'''
{| class="wikitable"
|-
! '''Access modifier'''
! '''Property'''
! '''API Field Name'''
! '''Return value'''
! '''Field length'''
|-
| Public ReadOnly Property
| '''ChargeREC_ID'''
| FLDSLPRECID
| As String
| 20
|-
| Public Property
| '''AccountREC_ID'''
| FLDSLPCARDID
| As String
| 20
|-
| Public Property
| '''EmployeeREC_ID'''
| FLDSLPWORKERID
| As String
| 20
|-
| Public Property
| '''ChargedItem'''
| FLDSLPITEMID
| As String
| 20
|-
| Public Property
| '''ContractREC_ID'''
| FLDSLPBCRECID
| As String
| 20
|-
| Public Property
| '''TicketREC_ID'''
| FLDSLPTICKETID
| As String
| 20
|-
| Public Property
| '''[Date]'''
| FLDSLPSLIPDATE
| As DateTime
| N/A
|-
| Public Property
| '''Description'''
| FLDSLPDESC
| As String
| Unlimited
|-
| Public Property
| '''Units_Hours'''
| FLDSLPQUANTITY
| As Double
| N/A
|-
| Public Property
| '''HourlyBased'''
| FLDSLPITEMUNITISHOUR
| As Boolean
| N/A
|-
| Public Property
| '''AdjustAmount'''
| FLDSLPADJUSTAMOUNT
| As Double
| N/A
|-
| Public Property
| '''AdjustPercent'''
| FLDSLPADJUSTPERCENT
| As Double
| N/A
|-
|Public
| '''AdjustType'''
| FLDSLPADJUSTTYPE
| As String
| 1
|-
| Public Property
| '''FromTime'''
| FLDSLPSTARTTIME
| As String
| N/A
|-
| Public Property
| '''ToTime'''
| FLDSLPENDTIME
| As String
| N/A
|-
| Public Property
| '''Price_Rate'''
| FLDSLPPRICE
| As Double
| N/A
|-
| Public Property
| '''Billable'''
| FLDSLPBILLKIND
| As String
| 1
|-
| Public Property
| '''Billed'''
| FLDSLPSTAGE
| As String
| 1
|-
| Public Property
| '''Field1'''
| FLDSLPUSER1
| As String
| 25
|-
| Public Property
| '''CreateUser'''
| FLDSLPCREATEUSER
| As String
| 20
|}
=== Quote Class ===
The '''CRM.Quote''' class derives from '''CRM.Object'''. The following table lists all exposed '''CRM.Quote''' properties.
'''Quote Properties Reference Table'''
{| class="wikitable"
|-
! '''Access modifier'''
! '''Property'''
! '''API Field Name'''
! '''Return value'''
! '''Field length'''
|-
| Public ReadOnly Property
| '''QuoteREC_ID'''
| FLDQTERECID
| As String
| 20
|-
| Public Property
| '''AccountREC_ID'''
| FLDQTEACCOUNTRECID
| As String
| 20
|-
| Public Property
| '''Status'''
| FLDQTESTATUS
| As String
| 1
|-
| Public Property
| '''BillToAddress'''
| FLDQTEBILLTOADDRESS
| As String
| Unlimited
|-
| Public Property
| '''BillToContactREC_ID'''
| FLDQTECONTACTRECID
| As String
| 20
|-
| Public Property
| '''QuoteDate'''
| FLDQTEQUOTEDATE
| As DateTime
| N/A
|-
| Public Property
| '''ShipToContactREC_ID'''
| FLDQTESHIPTOCONTACT
| As String
| 20
|-
| Public Property
| '''ShipToAddress'''
| FLDQTESHIPTOADDRESS
| As String
| Unlimited
|-
| Public Property
| '''ContractREC_ID'''
| FLDQTEBCRECID
| As String
| 20
|-
| Public Property
| '''HeaderNotes'''
| FLDQTEHEADERNOTES
| As String
| Unlimited
|-
| Public Property
| '''FooterNotes'''
| FLDQTEFOOTERNOTES
| As String
| Unlimited
|-
| Public ReadOnly Property
| '''TotalAfterTax'''
| FLDQTETOTALAFTERTAX
| As Double
| N/A
|-
| Public ReadOnly Property
| '''TotalTax1'''
| FLDQTETOTALTAX1
| As Double
| N/A
|-
| Public ReadOnly Property
| '''TotalTax2'''
| FLDQTETOTALTAX2
| As Double
| N/A
|-
| Public ReadOnly Property
| '''Tax1'''
| FLDQTETAX1
| As Double
| N/A
|-
| Public ReadOnly Property
| '''Tax2'''
| FLDQTETAX2
| As Double
| N/A
|-
| Public ReadOnly Property
| '''TotalAfterDiscount'''
| FLDQTETOTALAFTERDISC
| As Double
| N/A
|-
| Public ReadOnly Property
| '''Discount'''
| FLDQTEDISCOUNT
| As Double
| N/A
|-
| Public ReadOnly Property
| '''TotalForCustomer'''
| FLDQTETOTAL4CUSTOMER
| As Double
| N/A
|-
| Public Property
| '''IsPublic'''
| FLDQTEISPUBLIC
| As Boolean
| N/A
|-
| Public Property
| '''Audit'''
| FLDQTEAUDIT
| As String
| Unlimited
|-
| Public ReadOnly Property
| '''QuoteNumber'''
| FLDQTEQUOTENO
| As Integer
| N/A
|-
| Public Property
| '''QuoteName'''
| FLDQTEQUOTENAME
| As String
| 100
|-
| Public Property
| '''QuoteReference'''
| FLDQTEREFERENCE
| As String
| 20
|-
| Public Property
| '''ManagerRec_ID'''
| FLDQTEWORKERID
| As String
| 20
|-
| Public Property
| '''QuoteUserField1'''
| FLDQTEUSER1
| As String
| 30
|-
| Public Property
| '''QuoteUserField2'''
| FLDQTEUSER2
| As String
| 30
|-
| Public Property
| '''QuoteUserField3'''
| FLDQTEUSER3
| As String
| 30
|-
| Public Property
| '''QuoteNotes'''
| FLDQTENOTES
| As String
| Unlimited
|-
| Public ReadOnly Property
| '''WonConvertedTo'''
| FLDQTEWONCONVERTEDTO
| As String
| 1
|-
| Public ReadOnly Property
| '''SignatureEmail'''
| FLDQTECAFREEEMAIL
| As String
| 100
|-
| Public ReadOnly Property
| '''SignatureName'''
| FLDQTECAFREENAME
| As String
| 50
|-
| Public ReadOnly Property
| '''SignatureText'''
| FLDQTECAFREESIGNATRE
| As String
| 30
|-
| Public ReadOnly Property
| '''SignatureIPAddress'''
| FLDQTECAIPADDRESS
| As String
| 15
|-
| Public ReadOnly Property
| '''SignatureDateAndTime'''
| FLDQTECATIMESTAMP
| As DateTime
| N/A
|-
| Public ReadOnly Property
| '''SignatureWebUserName'''
| FLDQTECAWEBUSERNAME
| As String
| 70
|-
| Public ReadOnly Property
| '''SignatureWebUserREC_ID'''
| FLDQTECAWEBUSERRECID
| As String
| 20
|-
| Public ReadOnly Property
| '''CreatedByUser'''
| FLDQTECREATEUSER
| As String
| 20
|-
| Public ReadOnly Property
| '''LastUpdateByUser'''
| FLDQTEUPDATEUSER
| As String
| 20
|-
| Public ReadOnly Property
| '''CreatedDate'''
| FLDQTECREATEDATE
| As DateTime
| N/A
|-
| Public ReadOnly Property
| '''UpdateDate'''
| FLDQTEUPDATEDATE
| As DateTime
| 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'''
{| class="wikitable"
|-
! '''Access modifier'''
! '''Property'''
! '''API Field Name'''
! '''Return value'''
! '''Field length'''
|-
| Public ReadOnly Property
| '''QuoteLineREC_ID'''
| FLDQTLRECID
| As String
| 20
|-
| Public Property
| '''QuoteREC_ID'''
| FLDQTLQUOTERECID
| As String
| 20
|-
| Public Property
| '''ItemREC_ID'''
| FLDQTLITEMRECID
| As String
| 20
|-
| Public ReadOnly Property
| '''ItemGroup'''
| FLDQTLITEMTYPEGROUP
| As String
| 1
|-
| Public Property
| '''Quantity'''
| FLDQTLQUANTITY
| As Double
| N/A
|-
| Public Property
| '''Price'''
| FLDQTLPRICE
| As Double
| N/A
|-
| Public Property
| '''DiscountMarkup'''
| FLDQTLADJUST
| As String
| 1
|-
| Public ReadOnly Property
| '''DiscountTotalAmountForCustomer'''
| FLDQTLADJAMTDIS4CUST
| As Double
| N/A
|-
| Public ReadOnly Property
| '''DiscountPercentageForCustomer'''
| FLDQTLADJPERDIS4CUST
| As Double
| N/A
|-
| Public ReadOnly Property
| '''LineTotal'''
| FLDQTLBILLTOTAL
| As Double
| N/A
|-
| Public ReadOnly Property
| '''LineTotalForCustomer'''
| FLDQTLTOTAL4CUSTOMER
| As Double
| N/A
|-
| Public ReadOnly Property
| '''LineType'''
| FLDQTLLINETYPE
| As String
| 1
|-
| Public Property
| '''LineSortOrder'''
| FLDQTLORDER
| As Integer
| N/A
|-
| Public ReadOnly Property
| '''PriceForCustomerAfterMarkup'''
| FLDQTLPRICE4CUSTOMER
| As Double
| N/A
|-
| Public Property
| '''AdjustAmount'''
| FLDQTLADJUSTAMOUNT
| As Double
| N/A
|-
| Public Property
| '''AdjustPercent'''
| FLDQTLADJUSTPERCENT
| As Double
| N/A
|-
| Public Property
| '''AdjustType'''
| FLDQTLADJUSTTYPE
| As String
| 1
|-
| Public Property
| '''Description'''
| FLDQTLDESCRIPTION
| As String
| Unlimited
|-
| Public ReadOnly Property
| '''CreatedByUser'''
| FLDQTLCREATEUSER
| As String
| 20
|-
| Public ReadOnly Property
| '''LastUpdateByUser'''
| FLDQTLUPDATEUSER
| As String
| 20
|-
| Public ReadOnly Property
| '''CreatedDate'''
| FLDQTLCREATEDATE
| As DateTime
| N/A
|-
| Public ReadOnly Property
| '''UpdateDate'''
| FLDQTLUPDATEDATE
| As DateTime
| N/A
|}
|}
==== QuoteLine Helper Methods ====
Besides the get/set properties, QuoteLine supports number of helper methods.
'''QuoteLine Helper Methods Table'''
{| class="wikitable"
|-
! '''Access modifier'''
! '''Return value'''
! '''Property'''
| '''Arguments'''
! '''Description'''
|-
| Public
| Sub
| '''SetQuoteLineItem'''
| (ByVal sItemREC_ID As String, ByVal dblQuantity As Double, ByVal dblPrice As Double)
| Fills the appropriate fields for inserting Item type QuoteLine.
|-
| Public
| Sub
| '''SetQuoteLineItemWithDiscount'''
| (ByVal sItemREC_ID As String, ByVal dblQuantity As Double, ByVal dblPrice As Double, ByVal dblDiscount As Double, ByVal bByPercent As Boolean)
| Fills the appropriate fields for inserting Item type QuoteLine specifying a discount.
|-
| Public
| Sub
| '''SetQuoteLineItemWithMarkup'''
| (ByVal sItemREC_ID As String, ByVal dblQuantity As Double, ByVal dblPrice As Double, ByVal dblMarkup As Double, ByVal bByPercent As Boolean)
| Fills the appropriate fields for inserting Item type QuoteLine specifying a markup.
|-
| Public
| Sub
| '''SetQuoteLineText'''
| (ByVal sText As String)
| Sets the appropriate field for inserting Text type QuoteLine.
|-
| Public
| Sub
| '''MoveLineAboveLine'''
| (ByVal lnAbove As QuoteLine)
| 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
| Sub
| '''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
| Sub
| '''Delete'''
| ()
| Deletes the QuoteLine.
|}
=== Document Class ===
The '''CRM.Document''' class derives from '''CRM.Object''' and encapsulates the [[API_Reference_Manual#Document_Fields|Document Fields]].
The following table lists all exposed '''CRM.Document''' properties.
'''Document Properties Reference Table'''
{| class="wikitable"
|-
! '''Access modifier'''
! '''Property'''
! '''API Field Name'''
! '''Return value'''
! '''Field length'''
|-
| Public ReadOnly Property
| '''DocumentREC_ID'''
| FLDDOCRECID
| As String
| 20
|-
| Public Property
| '''DocumentDate'''
| FLDDOCDOCDATE
| As DateTime
| N/A
|-
| Public Property
| '''Subject'''
| FLDDOCDOCUMENTDESC
| As String
| 100
|-
| Public Property
| '''RelLinkREC_ID'''
| FLDDOCLINKRECID
| As String
| 20
|-
| Public Property
| '''AccountREC_ID'''
| FLDDOCCARDID
| As String
| 20
|-
| Public Property
| '''ContactREC_ID'''
| FLDDOCCONTACTID
| As String
| 20
|-
| Public Property
| '''Field1'''
| FLDDOCTRANSPORT
| As String
| 20
|-
| Public Property
| '''Field2'''
| FLDDOCFOLDER
| As String
| 20
|-
| Public Property
| '''Field3'''
| FLDDOCUMENTPLACE
| As String
| 20
|-
| Public Property
| '''FilePathAndName'''
| FLDDOCDOCUMENTNAME
| As String
| 240
|-
| Public Property
| '''Category'''
| FLDDOCTREEID
| As Integer
| N/A
|-
| Public Property
| '''EmployeeREC_ID'''
| FLDDOCWORKERID
| As String
| 20
|-
| Public Property
| '''CreatedByUser'''
| FLDDOCCREATEUSER
| As String
| 20
|-
| Public Property
| '''LastUpdateByUser'''
| FLDDOCUPDATEUSER
| As String
| 20
|}
=== HistoryNote Class ===
The '''CRM.HistoryNote''' class derives from '''CRM.Object''' and encapsulates the [[API_Reference_Manual#History_Note_Fields|History Note Fields]].
The following table lists all exposed '''CRM.HistoryNote''' properties.
'''HistoryNote Properties Reference Table'''
{| class="wikitable"
|-
! '''Access modifier'''
! '''Property'''
! '''API Field Name'''
! '''Return value'''
! '''Field length'''
|-
| Public ReadOnly Property
| '''HistoryNoteREC_ID'''
| FLDHISRECID
| As String
| 20
|-
| Public Property
| '''[Date]'''
| FLDHISNOTEDATETIME
| As DateTime
| N/A
|-
| Public Property
| '''Description'''
| FLDHISDESCRIPTION
| As String
| Unlimited
|-
| Public Property
| '''RelLinkREC_ID'''
| FLDHISLINKRECID
| As String
| 20
|-
| Public Property
| '''Field'''
| FLDHISUSER1
| As String
| 25
|-
| Public Property
| '''About'''
| FLDHISKIND
| As String
| 15
|-
| Public Property
| '''EmployeeREC_ID'''
| FLDHISWORKERID
| As String
| 20
|-
| Public Property
| '''AccountREC_ID'''
| FLDHISCARDID
| As String
| 20
|-
| Public Property
| '''Contact'''
| FLDHISCONTACTID
| As String
| 20
|-
| Public Property
| '''DocumentREC_ID'''
| FLDHISDOCID
| As String
| 20
|-
| Public Property
| '''CreatedByUser'''
| FLDHISCREATEUSER
| As String
| 20
|}
=== Item Class ===
The '''CRM.Item''' class derives from '''CRM.Object''' and encapsulates the [[API_Reference_Manual#Item_Fields|Item Fields]].
The following table lists all exposed '''CRM.Item''' properties.
'''Item Properties Reference Table'''
{| class="wikitable"
|-
! '''Access modifier'''
! '''Property'''
! '''API Field Name'''
! '''Return value'''
! '''Field length'''
|-
| Public ReadOnly Property
| '''ItemREC_ID'''
| FLDITMRECID
| As String
| 20
|-
| Public Property
| '''ItemGroup'''
| FLDITMITEMTYPEGROUP
| As String
| 1
|-
| Public Property
| '''ItemCode'''
| FLDITMITEMNO
| As String
| 30
|-
| Public Property
| '''ItemName'''
| FLDITMNAME
| As String
| 60
|-
| Public Property
| '''PriceSource'''
| FLDITMPRICESOURCE
| As String
| 1
|-
| Public Property
| '''PricePerHour_Unit'''
| FLDITMUNITISHOUR
| As String
| 1
|-
| Public Property
| '''Price'''
| FLDITMUNITPRICE
| As Double
| N/A
|-
| Public Property
| '''Cost'''
| FLDITMSTANDARDCOST
| As Double
| N/A
|-
| Public Property
| '''Tax1'''
| FLDITMTAXCODE1
| As String
| 3
|-
| Public Property
| '''Tax2'''
| FLDITMTAXCODE2
| As String
| 3
|-
| Public Property
| '''Tax3'''
| FLDITMTAXCODE3
| As String
| 3
|-
| Public Property
| '''DescriptionByName'''
| FLDITMDESCBYNAME
| As String
| 1
|-
| Public Property
| '''Description'''
| FLDITMDESC
| As String
| Unlimited
|-
| Public Property
| '''Suspend'''
| FLDITMSUSPENDED
| As String
| 1
|-
| Public Property
| '''Notes'''
| FLDITMNOTES
| As String
| Unlimited
|-
| Public Property
| '''Field1'''
| FLDITMUSER1
| As String
| 25
|-
| Public Property
| '''CreateUser'''
| FLDITMCREATEUSER
| As String
| 20
|}
=== KnowledgeBaseArticle Class ===
The '''CRM.KnowledgeBaseArticle''' class derives from '''CRM.Object''' and encapsulates the [[API_Reference_Manual#Knowledge_Base_Article_Fields|Knowledge Base Article Fields]].
The following table lists all exposed '''CRM.KnowledgeBaseArticle''' properties.
'''KnowledgeBaseArticle Properties Reference Table'''
{| class="wikitable"
|-
! '''Access modifier'''
! '''Property'''
! '''API Field Name'''
! '''Return value'''
! '''Field length'''
|-
| Public ReadOnly Property
| '''KnowledgeBaseArticleREC_ID'''
| FLDKBARECID
| As String
| 20
|-
| Public Property
| '''DocumentDate'''
| FLDKBACREATEDATE
| As DateTime
| N/A
|-
| Public Property
| '''Title'''
| FLDKBATITLE
| As String
| 250
|-
| Public Property
| '''Problem'''
| FLDKBAPROBLEM
| As String
| Unlimited
|-
| Public Property
| '''Solution'''
| FLDKBASOLUTION
| As String
| Unlimited
|-
| Public Property
| '''Status'''
| FLDKBASTATUS
| As String
| 1
|-
| Public Property
| '''Category'''
| FLDKBACATEGORY
| As String
| 100
|-
| Public Property
| '''[Public]'''
| FLDKBAISPUBLIC
| As String
| 1
|-
| Public Property
| '''CreatedByUser'''
| FLDKBACREATEUSER
| As String
| 20
|-
| Public Property
| '''LastUpdateByUser'''
| FLDKBAUPDATEUSER
| As String
| 20
|}
=== Opportunity Class ===
The '''CRM.Opportunity''' class derives from '''CRM.Object''' and encapsulates the [[API_Reference_Manual#Opportunity_Fields|Opportunity Fields]].
The following table lists all exposed '''CRM.Opportunity''' properties.
'''Opportunity Properties Reference Table'''
{| class="wikitable"
|-
! '''Access modifier'''
! '''Property'''
! '''API Field Name'''
! '''Return value'''
! '''Field length'''
|-
| Public ReadOnly Property
| '''OpportunityREC_ID'''
| FLDOPPRECID
| As String
| 20
|-
| Public Property
| '''OpportunityName'''
| FLDOPPNAME
| As String
| 50
|-
| Public Property
| '''OpportunityID'''
| FLDOPPUSERID
| As String
| 15
|-
| Public Property
| '''AccountREC_ID'''
| FLDOPPCARDID
| As String
| 20
|-
| Public Property
| '''Source'''
| FLDOPPSOURCE
| As String
| 30
|-
| Public Property
| '''CloseDate'''
| FLDOPPCLOSEDATE
| As DateTime
| N/A
|-
| Public Property
| '''Manager'''
| FLDOPPWORKERID
| As String
| 20
|-
| Public Property
| '''OpenDate'''
| FLDOPPOPENDATE
| As DateTime
| N/A
|-
| Public Property
| '''CloseByDate'''
| FLDOPPESTDATE
| As DateTime
| N/A
|-
| Public Property
| '''Amount'''
| FLDOPPAMOUNT
| As Double
| N/A
|-
| Public Property
| '''Probability'''
| FLDOPPPROBABILITY
| As Double
| N/A
|-
| Public Property
| '''Stage'''
| FLDOPPSTAGE
| As String
| 30
|-
| Public Property
| '''Status'''
| FLDOPPSTATUS
| As Integer
| N/A
|-
| Public Property
| '''ClosingAmount'''
| FLDOPPCLOSEAMOUNT
| As Double
| N/A
|-
| Public Property
| '''Description'''
| FLDOPPDESCRIPTION
| As String
| Unlimited
|-
| Public Property
| '''OpportunityType'''
| FLDOPPKIND
| As String
| 30
|-
| Public Property
| '''OpportunityReason'''
| FLDOPPREASON
| As String
| 30
|-
| Public Property
| '''Note'''
| FLDOPPNOTES
| As String
| Unlimited
|-
| Public Property
| '''Territory'''
| FLDOPPREGION
| As String
| 30
|-
| Public Property
| '''Field1'''
| FLDOPPUSER1
| As String
| 30
|-
| Public Property
| '''Field2'''
| FLDOPPUSER2
| As String
| 30
|-
| Public Property
| '''Field3'''
| FLDOPPUSER3
| As String
| 30
|-
| Public Property
| '''CreatedByUser'''
| FLDOPPCREATEUSER
| As String
| 20
|-
| Public Property
| '''LastUpdateByUser'''
| FLDOPPUPDATEUSER
| As String
| 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''' properties.
'''Contact Properties Reference Table'''
{| class="wikitable"
|-
! '''Access modifier'''
! '''Property'''
! '''API Field Name'''
! '''Return value'''
! '''Field length'''
|-
| Public ReadOnly Property
| '''ContactREC_ID'''
| FLDCRDRECID
| As String
| 20
|-
| Public Property
| '''ParentAccountREC_ID'''
| FLDCRDASSIGNCARDID
| As String
| 20
|-
| Public Property
| '''AccountType'''
| FLDCRDENTITYKIND
| As Integer
| N/A
|-
| Public Property
| '''CompanyName'''
| FLDCRDCOMPANY
| As String
| 60
|-
| Public Property
| '''Contact'''
| FLDCRDCONTACT
| As String
| 40
|-
| Public Property
| '''Salutation'''
| FLDCRDSUFFIX
| As String
| 20
|-
| Public Property
| '''Title'''
| FLDCRDTITLE
| As String
|-
| Public Property
| '''Department'''
| FLDCRDDEPARTMENT
| As String
| 35
|-
| Public Property
| '''Dear'''
| FLDCRDDEAR
| As String
| 20
|-
| Public Property
| '''LastName'''
| FLDCRDLASTNAME
| As String
| 20
|-
| Public Property
| '''AddressLine1'''
| FLDCRDADDRESS1
| As String
| 40
|-
| Public Property
| '''AddressLine2'''
| FLDCRDADDRESS2
| As String
| 40
|-
| Public Property
| '''AddressLine3'''
| FLDCRDADDRESS3
| As String
| 40
|-
| Public Property
| '''City'''
| FLDCRDCITY
| As String
| 30
|-
| Public Property
| '''Country'''
| FLDCRDCOUNTRY
| As String
| 20
|-
| Public Property
| '''Zip'''
| FLDCRDZIP
| As String
| 15
|-
| Public Property
| '''State'''
| FLDCRDSTATE
| As String
| 30
|-
| Public Property
| '''EmailAddress1'''
| FLDCRDEMAIL1
| As String
| 70
|-
| Public Property
| '''Phone1'''
| FLDCRDPHONE1
| As String
| 25
|-
| Public Property
| '''Phone2'''
| FLDCRDPHONE2
| As String
| 25
|-
| Public Property
| '''FaxNumber'''
| FLDCRDFAX1
| As String
| 25
|-
| Public Property
| '''Phone1Ext'''
| FLDCRDPHNDESC1
| As String
| 40
|-
| Public Property
| '''Phone2Ext'''
| FLDCRDPHNDESC2
| As String
| 40
|-
| Public Property
| '''FaxNumberExt'''
| FLDCRDFAXDESC1
| As String
| 15
|-
| Public Property
| '''SubContractCode'''
| FLDCRDSUBCODE
| As String
| 15
|-
| Public Property
| '''Birthday'''
| FLDCRDBIRTHDAY
| As DateTime
| N/A
|-
| Public Property
| '''Notes'''
| FLDCRDNOTES
| As String
| Unlimited
|-
| Public Property
| '''CreationDate'''
| FLDCRDCREATEDATE
| As DateTime
| N/A
|-
| Public Property
| '''CreatedByUser'''
| FLDCRDCREATEUSERID
| As String
| 20
|-
| Public Property
| '''LastUpdatedBy'''
| FLDCRDUPDATEUSERID
| As String
| 20
|}
== Config Class ==
'''CRM.Config''' class is used to pass the global configuration settings to the '''CRM.Application Initialize''' method.
{| class="wikitable"
|-
! '''Property'''
! '''Type'''
! '''Required'''
! '''Description'''
|-
| '''AppName'''
| String
| '''Yes'''
| Maximum 15 chars, string that best identifies your application.
|-
| '''DllFolder'''
| String
| '''Yes'''
| Exact path to the folder where RangerMSP API DLLs are located ('''CmtDbEng.dll''' and '''CmtDbQry.dll''', usually '''"C:\RangerMSP\ThirdParty\UserDev"''').
|-
| '''DbFolder'''
| String
| '''Yes'''
| Exact path to the folder where RangerMSP database is located (usually '''"C:\RangerMSP\db"''').
|-
| '''InitCRMApiDll'''
| 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.
|-
| '''InitCRMQryDll'''
| Boolean
| 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(Of KeyValuePair(Of String, String))
| No
| Not used, reserved for future use
|-
| '''RaiseExceptionIfDatabaseFieldTruncated'''
| Boolean
| 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 [http://en.wikipedia.org/wiki/Singleton_pattern Singleton pattern] that hold all global defined application settings and is used for easy access to these settings. Once the main CRM.Application object is initialized, you can refer to this instance by writing: CRM.Application.instance().
Table below lists the CRM.Application properties.
{| class="wikitable"
|-
! '''Property'''
! '''Type'''
! '''Description'''
|-
| '''config'''
| Config
| Access to the CRM.Config object passed in CRM.Application.Initialize method.
|-
| '''CmtDateFormat'''
| String
| 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).
|-
| '''CmtDateSeparator'''
| String
| Separator between the date ranges, usually '/', '-' or '.'.
|-
| '''CmtTimeFormat'''
| String
| Global RangerMSP time format.
|-
| '''CmtIsTimeFormatAMPMInUse'''
| Boolean
| 12 hour or 24 hour time format.
|}
Table below list the CRM.Application methods.
{| class="wikitable"
|-
! '''Access modifier'''
! '''Method'''
! '''Arguments'''
! '''Return value'''
! '''Description'''
|-
| Public Shared Function
| '''instance'''
| ()
| Application
| Method that returns the singleton object. Use it to access all CRM.Application properties/methods.
|-
| Public Shared Sub
| '''Initialize'''
| (ByVal c As Config)
|
| Method that initializes the internal RangerMSP API DLLs. Must be the first call before using any other RangerMSP library calls.
|-
| Public Shared Sub
| '''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 property '''FileAs''' ('''CRM.Account.FileAs'''). To this property corresponds one shared object instance of the '''CRM.CrmField''' class accessible through '''CRM.Account.Fields.FileAs'''. To the property '''LastName''' ('''CRM.Account.LastName'''), corresponds the shared object '''CRM.Account.Fields.LastName''' of type '''CRM.CrmField'''. And so on, for each property in each class.
Below is a table that lists the properties available in the '''CRM.CrmField''' class.
{| class="wikitable"
|-
! '''Property'''
! '''Type'''
! '''Description'''
|-
| '''Key'''
| String
| The internal database field key (as FLDCRDFULLNAME or FLDCRDLASTNAME, etc.)
|-
| '''Type'''
| String
| Internal database field type (as CHAR, MEMO, DOUBLE, TIMESTAMP, etc.)
|-
| '''Size'''
| Integer
| Maximum allowed length for the field data (applies to CHAR Type).
|-
| '''Label'''
| String
| Label for the field
|-
| '''Hint'''
| String
|
|-
| '''Name'''
| String
|
|-
| '''DefaultValue'''
| String
| Default value for the field
|-
| '''DisplaySymbol'''
| String
| 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:
<font face="courier new" size="3">
<span style="color: #66AD3A;">'charge is of type '''CRM.Charge''' and is previously initialized</span>
Console.Out.Write(charge.AdjustAmount.ToString() + CRM.Charge.Fields.AdjustAmount.DisplaySymbol)
</font>
== ObjectQuery Class ==
'''CRM.ObjectQuery''' is a generics 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:
<font face="courier new" size="3">
<span style="color: #3A3AFF;">Dim</span> ticketSearch <span style="color: #3A3AFF;">As New</span> CRM.ObjectQuery(<span style="color: #3A3AFF;">Of</span> CRM.Ticket)
<span style="color: #66AD3A;">'account is previously initialized</span>
ticketSearch.AddCriteria(CRM.Ticket.Fields.AccountREC_ID, CRM.OperatorEnum.opEqual, account.AccountREC_ID)
ticketSearch.AddCriteria(CRM.Ticket.Fields.UpdateDate, CRM.OperatorEnum.opGreaterThanOrEqual, DateTime.Parse(<span style="color: #963A46;">"01 Jan 2011"</span>))
<span style="color: #3A3AFF;">Dim</span> tickets <span style="color: #3A3AFF;">As</span> List(<span style="color: #3A3AFF;">Of</span> CRM.Ticket) = ticketSearch.FetchObjects()
<span style="color: #66AD3A;">'tickets now contains all CRM.Ticket objects that satisfy the above criteria.</span>
</font>
By default, '''CRM.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:
<font face="courier new" size="3">
<span style="color: #3A3AFF;">Dim</span> accountSearch <span style="color: #3A3AFF;">As New</span> CRM.ObjectQuery(<span style="color: #3A3AFF;">Of</span> CRM.Account)(CRM.LinkEnum.linkOR)
accountSearch.AddCriteria(CRM.Account.Fields.City, CRM.OperatorEnum.opEqual, <span style="color: #963A46;">"New York"</span>)
accountSearch.AddCriteria(CRM.Account.Fields.City, CRM.OperatorEnum.opEqual, <span style="color: #963A46;">"Chicago"</span>)
<span style="color: #3A3AFF;">Dim</span> accounts <span style="color: #3A3AFF;">As</span> List(<span style="color: #3A3AFF;">Of</span> CRM.Account) = accountSearch.FetchObjects()
<span style="color: #66AD3A;">'accounts now contains all CRM.Account objects that satisfy any of the above criteria.</span>
</font>
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 '''CRM.ObjectQuery.FetchObjects''' and the objects in the results will have only those fields populated.
<font face="courier new" size="3">
<span style="color: #3A3AFF;">Dim</span> accountSearch <span style="color: #3A3AFF;">As New</span> CRM.ObjectQuery(<span style="color: #3A3AFF;">Of</span> CRM.Account)(CRM.LinkEnum.linkOR)
accountSearch.AddCriteria(CRM.Account.Fields.City, CRM.OperatorEnum.opEqual, <span style="color: #963A46;">"New York"</span>)
accountSearch.AddCriteria(CRM.Account.Fields.City, CRM.OperatorEnum.opEqual, <span style="color: #963A46;">"Chicago"</span>)
<span style="color: #3A3AFF;">Dim</span> accounts <span style="color: #3A3AFF;">As</span> List(<span style="color: #3A3AFF;">Of</span> CRM.Account) = accountSearch.FetchObjects(CRM.Account.Fields.AccountREC_ID.Key & "," & CRM.Account.Fields.City.Key)
<span style="color: #66AD3A;">'CRM.Account objects in the accounts list now contain only the AccountREC_ID and City fields.</span>
</font>
The table below explains the important methods of the '''CRM.ObjectQuery''' class:
{| class="wikitable"
|-
! '''Access modifier'''
! '''Method'''
! '''Arguments'''
! '''Return value'''
! '''Description'''
|-
| Public Sub
| '''AddCriteria'''
| (ByVal sField As String, ByVal opEnum As OperatorEnum, ByVal sValue As String)
|
| 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 Sub
| '''AddCriteria'''
| (ByVal field As CrmField, ByVal opEnum As OperatorEnum, ByVal sValue As String)
|
| 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 ('''System.String''') to search for. This variation (or the one variations with the '''System.DateTime''' or '''System.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 Sub
| '''AddCriteria'''
| (ByVal field As CrmField, ByVal opEnum As OperatorEnum, ByVal dtValue As DateTime)
|
| 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 ('''System.DateTime''') to search for. Use this variation to search in fields that are of '''DateTime''' type.
|-
| Public Sub
| '''AddCriteria'''
| (ByVal field As CrmField, ByVal opEnum As OperatorEnum, ByVal nValue As Integer)
|
| 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 ('''System.Integer''') to search for. Use this variation to search in fields that are of '''Integer''' type.
|-
| Public Sub
| '''AddCriteria'''
| (ByVal field As CrmField, ByVal opEnum As OperatorEnum, ByVal nValue As Double)
|
| 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 ('''System.Double''') to search for. Use this variation to search in fields that are of '''Double''' type.
|-
| Public Sub
| '''AddSortExpression'''
| (ByVal sField As String, ByVal sortEnum As SortDirectionEnum)
|
| 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 Sub
| '''AddSortExpression'''
| (ByVal field As CrmField, ByVal sortEnum As SortDirectionEnum)
|
| 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 Function
| '''FetchObjects'''
| ()
| As List(Of T)
| Executes the constructed query and returns a list of objects (of type '''T''' where T 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.
{| class="wikitable"
|-
! 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:
<font face="courier new" size="3">
<span style="color: #3A3AFF;">Dim</span> config <span style="color: #3A3AFF;">As New</span> CRM.Config
config.AppName = <span style="color: #963A46;">"VB.NET Demo"</span>
config.DllFolder = <span style="color: #963A46;">"C:\RangerMSP\ThirdParty\UserDev"</span>
config.DbFolder = <span style="color: #963A46;">"C:\RangerMSP\db"</span>
config.RaiseExceptionIfDatabaseFieldTruncated = <span style="color: #3A3AFF;">True</span><span style="color: #66AD3A;">'the setting is ON now</span>
<span style="color: #66AD3A;">'Initialize the CRM.Application</span>
CRM.Application.Initialize(config)
<span style="color: #3A3AFF;">Dim</span> account <span style="color: #3A3AFF;">As New</span> CRM.Account
account.FileAs = <span style="color: #963A46;">"ACME Company"</span>
account.Dear = <span style="color: #963A46;">"Mr."</span>
account.Contact = <span style="color: #963A46;">"John Doe"</span>
<span style="color: #66AD3A;">'the following line of code will throw an exception because we try to assign more than 40 chars to AddressLine1</span>
account.AddressLine1 = <span style="color: #963A46;">"More than forty characters of the main address line"</span><span style="color: #66AD3A;">'Exception is thrown here</span>
account.Save()
</font>


= See Also =
= See Also =
*[[Commit API Developers Guide]]
*[[API Developers Guide|RangerMSP API Developers Guide]]
*[[API Reference Manual]]
*[[API Reference Manual]]
[[Category:User Manuals]]
[[Category:User Manuals]]
[[Category:Integration]]
[[Category:Integration]]

Latest revision as of 10:25, 9 July 2020

User Manuals > API Developers Guide > VB.NET API

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 VB.NET 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 Basic .NET 2008 or Visual Basic .NET 2010.
  • CRMLib.dll (the RangerMSP VB.NET compiled library).

Getting Started

Libraries Setup

To download, compile and setup the libraries, please refer to VB.NET API Library Setup.

Start Basic Program

After you create your VB.NET project, you'll need to add a reference to the CRMLib.dll 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:

Dim config As New CRM.Config
config.AppName = "VB.NET 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.mycrmserver.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:

Dim config As New CRM.Config
config.AppName = "VB.NET 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:

'CRM.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 CRM.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 VB.NET application that just connects to RangerMSP and terminates could look something like this:

Try
    Dim config As New CRM.Config
    config.AppName = "VB.NET Demo"
    config.DllFolder = "C:\RangerMSP\ThirdParty\UserDev"
    config.DbFolder = "C:\RangerMSP\db"

    CRM.Application.Initialize(config)

    'At this point we have successfully initialized the CRM.Application
    'and can start using the other library classes
Catch ex As Exception 
    Console.Out.Write(ex.Message)
Finally
    CRM.Application.Terminate()
End Try

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 VB.NET 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.

Dim accountSearch As New CRM.ObjectQuery(Of CRM.Account)

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.Ticket.Fields.City, CRM.OperatorEnum.opEqual, "New York")

The first parameter to the AddCriteria method is either a Shared 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):

Dim accounts As List(Of CRM.Account) = accountSearch.FetchObjects()

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

For Each account In accounts
    Console.Out.WriteLine(account.CompanyName)
Next

Or we can manipulate these accounts:

For Each account In accounts
    If account.Zip.Length = 0 Then
        account.Zip = "10001"
        account.Save()
    End If
Next

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:

For Each account In accounts
    Dim ticket As New CRM.Ticket
    ticket.AccountREC_ID = account.AccountREC_ID
    ticket.Description = "Sample ticket for a NewYork account"
    ticket.Save()
Next

GetFieldValue and SetFieldValue methods

Each of the RangerMSP library objects have a set of properties that are exposed as VB.NET 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 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 properties:

For Each account In accounts
    Dim ticket As New CRM.Ticket
    ticket.SetFieldValue("FLDTKTCARDID", account.GetFieldValue("FLDCRDRECID"))
    ticket.SetFieldValue("FLDTKTPROBLEM", "Sample ticket for a NewYork account")
    ticket.Save()
Next

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

Exception Handling

While working with the RangerMSP VB.NET 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 ocured when an exception is thrown, you can inspect the CRM.Exception.Status property that holds the last RangerMSP Status value, or inspect the list of CRM.Exception.Codes (if any). Please refer to Error Codes Description for the description of these values.

Complete Program Sample

Module Module1

    Sub Main()

        Try
            'Setup the CRM.Config object
            Dim config As New CRM.Config
            config.AppName = "VB.NET Demo"
            config.DllFolder = "C:\RangerMSP\ThirdParty\UserDev"
            config.DbFolder = "C:\RangerMSP\db"

            'Initialize the CRM.Application
            CRM.Application.Initialize(config)

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

            'search for "New York" in the FLDCRDCITY field
            Dim accountSearch As New CRM.ObjectQuery(Of CRM.Account)
            accountSearch.AddCriteria("FLDCRDCITY", CRM.OperatorEnum.opEqual, "New York")
            Dim accounts As List(Of CRM.Account) = accountSearch.FetchObjects()

            'loop through the retrieved accounts and output the CompanyName
            For Each account In accounts
                Console.Out.WriteLine(account.CompanyName)
            Next

       Catch ex As CRM.Exception 'here we catch RangerMSP specific error
            'we can inspect the RangerMSP status (exc.Status) 
            'exc.Codes contains all error codes last call generated

            'here we show the error message
            Console.Out.Write(ex.Message)

        Catch ex As Exception 
            Console.Out.Write(ex.Message)
        Finally
            CRM.Application.Terminate()
        End Try
    End Sub

End Module

Classes and Objects

The RangerMSP VB.NET 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 (properties) 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:

Dim account As New CRM.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 routines and functions exposed by the CRM.Object class are available to the derived classes.

Object Method Reference Table

Access modifier Method Arguments Return value Description
Public Sub SetFieldValue (sKey As String, sValue As String) 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 Function GetFieldValue (sKey As String) As String Retrieves the value of the field passed in sKey argument. Use this method to access user-defined custom fields.
Public Sub 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 Sub Reinit (sID As String) Same as Reload except the unique identifier is passed as argument.
Public Sub 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 properties.

Account Properties Reference Table

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

Ticket Class

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

Ticket Properties Reference Table

Access modifier Property API Field Name Return value Field length
Public ReadOnly Property TicketREC_ID FLDTKTRECID As String 20
Public Property AccountREC_ID FLDTKTCARDID As String 20
Public Property AssetREC_ID FLDTKTASSETRECID As String 20
Public Property ContactREC_ID FLDTKTCONTACTID As String 20
Public Property ContractREC_ID FLDTKTBCRECID As String 20
Public Property EmployeeREC_ID FLDTKTWORKERID As String 20
Public Property TicketPriority FLDTKTPRIORITY As Integer N/A
Public Property TicketNumber FLDTKTTICKETNO As String 20
Public Property Description FLDTKTPROBLEM As String Unlimited
Public Property TicketType FLDTKTKIND As String 25
Public Property Source FLDTKTSOURCE As String 30
Public Property EstimatedDurationTime FLDTKTSCHEDLENESTIM As Integer N/A
Public Property ShowTicketInDispatcher FLDTKTFORDISPATCH As String 1
Public Property Status FLDTKTSTATUS As Integer N/A
Public Property CreatedByUser FLDTKTCREATEUSER As String 20
Public Property DueDate FLDTKTDUEDATETIME As DateTime N/A
Public Property Resolution FLDTKTSOLUTION As String Unlimited
Public ReadOnly Property UpdateDate FLDTKTUPDATEDATE As DateTime 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 properties.

Asset Properties Reference Table

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

Calendar Properties Reference Table

Access modifier Property API Field Name Return value Field length
Public ReadOnly Property CalendarREC_ID FLDEVTRECID As String 20
Public Property EventType FLDEVTWRITETOID As Integer N/A
Public Property EmployeeREC_ID FLDEVTWORKERID As String 20
Public Property PrivateUser FLDEVTPRIVATEID As String 20
Public Property AccountREC_ID FLDEVTCARDID As String 20
Public Property ContactREC_ID FLDEVTCONTACTID As String 20
Public Property DocumentREC_ID FLDEVTDOCID As String 20
Public Property DoneIndication FLDEVTDONE As Boolean N/A
Public Property [Date] FLDEVTEVENTDATE As DateTime N/A
Public Property Description FLDEVTFREETEXT As String Unlimited
Public Property TimeStart FLDEVTFROMTIME As String N/A
Public Property TimeEnd FLDEVTTOTIME As String N/A
Public Property RelLinkREC_ID FLDEVTLINKRECID As String 20
Public Property Field1 FLDEVTFAMILY As String 50
Public Property Field2 FLDEVTACTION As String 50
Public Property Field3 FLDEVTPLACE As String 40
Public Property Field4 FLDEVTPLACE1 As String 30
Public Property Field5 FLDEVTPLACE2 As String 30
Public Property CreatedByUser FLDEVTCREATEUSERID As String 20
Public Property LastUpdateByUser FLDEVTUPDATEUSER As String 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 properties.

Task Properties Reference Table

Access modifier Property API Field Name Return value Field length
Public ReadOnly Property TaskREC_ID FLDEVTRECID As String 20
Public Property EventType FLDEVTWRITETOID As Integer N/A
Public Property EmployeeREC_ID FLDEVTWORKERID As String 20
Public Property PrivateUser FLDEVTPRIVATEID As String 20
Public Property AccountREC_ID FLDEVTCARDID As String 20
Public Property ContactREC_ID FLDEVTCONTACTID As String 20
Public Property DocumentREC_ID FLDEVTDOCID As String 20
Public Property DoneIndication FLDEVTDONE As Boolean N/A
Public Property [Date] FLDEVTEVENTDATE As DateTime N/A
Public Property Description FLDEVTFREETEXT As String Unlimited
Public Property TimeStart FLDEVTFROMTIME As String N/A
Public Property RelLinkREC_ID FLDEVTLINKRECID As String 20
Public Property Field1 FLDEVTFAMILY As String 50
Public Property Field2 FLDEVTACTION As String 50
Public Property Field3 FLDEVTPLACE As String 40
Public Property Field4 FLDEVTPLACE1 As String 30
Public Property Field5 FLDEVTPLACE2 As String 30
Public Property CreatedByUser FLDEVTCREATEUSERID As String 20
Public Property LastUpdateByUser FLDEVTUPDATEUSER As String 20

Charge Class

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

Charge Properties Reference Table

Access modifier Property API Field Name Return value Field length
Public ReadOnly Property ChargeREC_ID FLDSLPRECID As String 20
Public Property AccountREC_ID FLDSLPCARDID As String 20
Public Property EmployeeREC_ID FLDSLPWORKERID As String 20
Public Property ChargedItem FLDSLPITEMID As String 20
Public Property ContractREC_ID FLDSLPBCRECID As String 20
Public Property TicketREC_ID FLDSLPTICKETID As String 20
Public Property [Date] FLDSLPSLIPDATE As DateTime N/A
Public Property Description FLDSLPDESC As String Unlimited
Public Property Units_Hours FLDSLPQUANTITY As Double N/A
Public Property HourlyBased FLDSLPITEMUNITISHOUR As Boolean N/A
Public Property AdjustAmount FLDSLPADJUSTAMOUNT As Double N/A
Public Property AdjustPercent FLDSLPADJUSTPERCENT As Double N/A
Public AdjustType FLDSLPADJUSTTYPE As String 1
Public Property FromTime FLDSLPSTARTTIME As String N/A
Public Property ToTime FLDSLPENDTIME As String N/A
Public Property Price_Rate FLDSLPPRICE As Double N/A
Public Property Billable FLDSLPBILLKIND As String 1
Public Property Billed FLDSLPSTAGE As String 1
Public Property Field1 FLDSLPUSER1 As String 25
Public Property CreateUser FLDSLPCREATEUSER As String 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 Property API Field Name Return value Field length
Public ReadOnly Property QuoteREC_ID FLDQTERECID As String 20
Public Property AccountREC_ID FLDQTEACCOUNTRECID As String 20
Public Property Status FLDQTESTATUS As String 1
Public Property BillToAddress FLDQTEBILLTOADDRESS As String Unlimited
Public Property BillToContactREC_ID FLDQTECONTACTRECID As String 20
Public Property QuoteDate FLDQTEQUOTEDATE As DateTime N/A
Public Property ShipToContactREC_ID FLDQTESHIPTOCONTACT As String 20
Public Property ShipToAddress FLDQTESHIPTOADDRESS As String Unlimited
Public Property ContractREC_ID FLDQTEBCRECID As String 20
Public Property HeaderNotes FLDQTEHEADERNOTES As String Unlimited
Public Property FooterNotes FLDQTEFOOTERNOTES As String Unlimited
Public ReadOnly Property TotalAfterTax FLDQTETOTALAFTERTAX As Double N/A
Public ReadOnly Property TotalTax1 FLDQTETOTALTAX1 As Double N/A
Public ReadOnly Property TotalTax2 FLDQTETOTALTAX2 As Double N/A
Public ReadOnly Property Tax1 FLDQTETAX1 As Double N/A
Public ReadOnly Property Tax2 FLDQTETAX2 As Double N/A
Public ReadOnly Property TotalAfterDiscount FLDQTETOTALAFTERDISC As Double N/A
Public ReadOnly Property Discount FLDQTEDISCOUNT As Double N/A
Public ReadOnly Property TotalForCustomer FLDQTETOTAL4CUSTOMER As Double N/A
Public Property IsPublic FLDQTEISPUBLIC As Boolean N/A
Public Property Audit FLDQTEAUDIT As String Unlimited
Public ReadOnly Property QuoteNumber FLDQTEQUOTENO As Integer N/A
Public Property QuoteName FLDQTEQUOTENAME As String 100
Public Property QuoteReference FLDQTEREFERENCE As String 20
Public Property ManagerRec_ID FLDQTEWORKERID As String 20
Public Property QuoteUserField1 FLDQTEUSER1 As String 30
Public Property QuoteUserField2 FLDQTEUSER2 As String 30
Public Property QuoteUserField3 FLDQTEUSER3 As String 30
Public Property QuoteNotes FLDQTENOTES As String Unlimited
Public ReadOnly Property WonConvertedTo FLDQTEWONCONVERTEDTO As String 1
Public ReadOnly Property SignatureEmail FLDQTECAFREEEMAIL As String 100
Public ReadOnly Property SignatureName FLDQTECAFREENAME As String 50
Public ReadOnly Property SignatureText FLDQTECAFREESIGNATRE As String 30
Public ReadOnly Property SignatureIPAddress FLDQTECAIPADDRESS As String 15
Public ReadOnly Property SignatureDateAndTime FLDQTECATIMESTAMP As DateTime N/A
Public ReadOnly Property SignatureWebUserName FLDQTECAWEBUSERNAME As String 70
Public ReadOnly Property SignatureWebUserREC_ID FLDQTECAWEBUSERRECID As String 20
Public ReadOnly Property CreatedByUser FLDQTECREATEUSER As String 20
Public ReadOnly Property LastUpdateByUser FLDQTEUPDATEUSER As String 20
Public ReadOnly Property CreatedDate FLDQTECREATEDATE As DateTime N/A
Public ReadOnly Property UpdateDate FLDQTEUPDATEDATE As DateTime 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 Property API Field Name Return value Field length
Public ReadOnly Property QuoteLineREC_ID FLDQTLRECID As String 20
Public Property QuoteREC_ID FLDQTLQUOTERECID As String 20
Public Property ItemREC_ID FLDQTLITEMRECID As String 20
Public ReadOnly Property ItemGroup FLDQTLITEMTYPEGROUP As String 1
Public Property Quantity FLDQTLQUANTITY As Double N/A
Public Property Price FLDQTLPRICE As Double N/A
Public Property DiscountMarkup FLDQTLADJUST As String 1
Public ReadOnly Property DiscountTotalAmountForCustomer FLDQTLADJAMTDIS4CUST As Double N/A
Public ReadOnly Property DiscountPercentageForCustomer FLDQTLADJPERDIS4CUST As Double N/A
Public ReadOnly Property LineTotal FLDQTLBILLTOTAL As Double N/A
Public ReadOnly Property LineTotalForCustomer FLDQTLTOTAL4CUSTOMER As Double N/A
Public ReadOnly Property LineType FLDQTLLINETYPE As String 1
Public Property LineSortOrder FLDQTLORDER As Integer N/A
Public ReadOnly Property PriceForCustomerAfterMarkup FLDQTLPRICE4CUSTOMER As Double N/A
Public Property AdjustAmount FLDQTLADJUSTAMOUNT As Double N/A
Public Property AdjustPercent FLDQTLADJUSTPERCENT As Double N/A
Public Property AdjustType FLDQTLADJUSTTYPE As String 1
Public Property Description FLDQTLDESCRIPTION As String Unlimited
Public ReadOnly Property CreatedByUser FLDQTLCREATEUSER As String 20
Public ReadOnly Property LastUpdateByUser FLDQTLUPDATEUSER As String 20
Public ReadOnly Property CreatedDate FLDQTLCREATEDATE As DateTime N/A
Public ReadOnly Property UpdateDate FLDQTLUPDATEDATE As DateTime N/A

QuoteLine Helper Methods

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

QuoteLine Helper Methods Table

Access modifier Return value Property Arguments Description
Public Sub SetQuoteLineItem (ByVal sItemREC_ID As String, ByVal dblQuantity As Double, ByVal dblPrice As Double) Fills the appropriate fields for inserting Item type QuoteLine.
Public Sub SetQuoteLineItemWithDiscount (ByVal sItemREC_ID As String, ByVal dblQuantity As Double, ByVal dblPrice As Double, ByVal dblDiscount As Double, ByVal bByPercent As Boolean) Fills the appropriate fields for inserting Item type QuoteLine specifying a discount.
Public Sub SetQuoteLineItemWithMarkup (ByVal sItemREC_ID As String, ByVal dblQuantity As Double, ByVal dblPrice As Double, ByVal dblMarkup As Double, ByVal bByPercent As Boolean) Fills the appropriate fields for inserting Item type QuoteLine specifying a markup.
Public Sub SetQuoteLineText (ByVal sText As String) Sets the appropriate field for inserting Text type QuoteLine.
Public Sub MoveLineAboveLine (ByVal lnAbove As QuoteLine) 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 Sub 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 Sub 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 properties.

Document Properties Reference Table

Access modifier Property API Field Name Return value Field length
Public ReadOnly Property DocumentREC_ID FLDDOCRECID As String 20
Public Property DocumentDate FLDDOCDOCDATE As DateTime N/A
Public Property Subject FLDDOCDOCUMENTDESC As String 100
Public Property RelLinkREC_ID FLDDOCLINKRECID As String 20
Public Property AccountREC_ID FLDDOCCARDID As String 20
Public Property ContactREC_ID FLDDOCCONTACTID As String 20
Public Property Field1 FLDDOCTRANSPORT As String 20
Public Property Field2 FLDDOCFOLDER As String 20
Public Property Field3 FLDDOCUMENTPLACE As String 20
Public Property FilePathAndName FLDDOCDOCUMENTNAME As String 240
Public Property Category FLDDOCTREEID As Integer N/A
Public Property EmployeeREC_ID FLDDOCWORKERID As String 20
Public Property CreatedByUser FLDDOCCREATEUSER As String 20
Public Property LastUpdateByUser FLDDOCUPDATEUSER As String 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 properties.

HistoryNote Properties Reference Table

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

Item Class

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

Item Properties Reference Table

Access modifier Property API Field Name Return value Field length
Public ReadOnly Property ItemREC_ID FLDITMRECID As String 20
Public Property ItemGroup FLDITMITEMTYPEGROUP As String 1
Public Property ItemCode FLDITMITEMNO As String 30
Public Property ItemName FLDITMNAME As String 60
Public Property PriceSource FLDITMPRICESOURCE As String 1
Public Property PricePerHour_Unit FLDITMUNITISHOUR As String 1
Public Property Price FLDITMUNITPRICE As Double N/A
Public Property Cost FLDITMSTANDARDCOST As Double N/A
Public Property Tax1 FLDITMTAXCODE1 As String 3
Public Property Tax2 FLDITMTAXCODE2 As String 3
Public Property Tax3 FLDITMTAXCODE3 As String 3
Public Property DescriptionByName FLDITMDESCBYNAME As String 1
Public Property Description FLDITMDESC As String Unlimited
Public Property Suspend FLDITMSUSPENDED As String 1
Public Property Notes FLDITMNOTES As String Unlimited
Public Property Field1 FLDITMUSER1 As String 25
Public Property CreateUser FLDITMCREATEUSER As String 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 properties.

KnowledgeBaseArticle Properties Reference Table

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

Opportunity Class

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

Opportunity Properties Reference Table

Access modifier Property API Field Name Return value Field length
Public ReadOnly Property OpportunityREC_ID FLDOPPRECID As String 20
Public Property OpportunityName FLDOPPNAME As String 50
Public Property OpportunityID FLDOPPUSERID As String 15
Public Property AccountREC_ID FLDOPPCARDID As String 20
Public Property Source FLDOPPSOURCE As String 30
Public Property CloseDate FLDOPPCLOSEDATE As DateTime N/A
Public Property Manager FLDOPPWORKERID As String 20
Public Property OpenDate FLDOPPOPENDATE As DateTime N/A
Public Property CloseByDate FLDOPPESTDATE As DateTime N/A
Public Property Amount FLDOPPAMOUNT As Double N/A
Public Property Probability FLDOPPPROBABILITY As Double N/A
Public Property Stage FLDOPPSTAGE As String 30
Public Property Status FLDOPPSTATUS As Integer N/A
Public Property ClosingAmount FLDOPPCLOSEAMOUNT As Double N/A
Public Property Description FLDOPPDESCRIPTION As String Unlimited
Public Property OpportunityType FLDOPPKIND As String 30
Public Property OpportunityReason FLDOPPREASON As String 30
Public Property Note FLDOPPNOTES As String Unlimited
Public Property Territory FLDOPPREGION As String 30
Public Property Field1 FLDOPPUSER1 As String 30
Public Property Field2 FLDOPPUSER2 As String 30
Public Property Field3 FLDOPPUSER3 As String 30
Public Property CreatedByUser FLDOPPCREATEUSER As String 20
Public Property LastUpdateByUser FLDOPPUPDATEUSER As String 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 properties.

Contact Properties Reference Table

Access modifier Property API Field Name Return value Field length
Public ReadOnly Property ContactREC_ID FLDCRDRECID As String 20
Public Property ParentAccountREC_ID FLDCRDASSIGNCARDID As String 20
Public Property AccountType FLDCRDENTITYKIND As Integer N/A
Public Property CompanyName FLDCRDCOMPANY As String 60
Public Property Contact FLDCRDCONTACT As String 40
Public Property Salutation FLDCRDSUFFIX As String 20
Public Property Title FLDCRDTITLE As String
Public Property Department FLDCRDDEPARTMENT As String 35
Public Property Dear FLDCRDDEAR As String 20
Public Property LastName FLDCRDLASTNAME As String 20
Public Property AddressLine1 FLDCRDADDRESS1 As String 40
Public Property AddressLine2 FLDCRDADDRESS2 As String 40
Public Property AddressLine3 FLDCRDADDRESS3 As String 40
Public Property City FLDCRDCITY As String 30
Public Property Country FLDCRDCOUNTRY As String 20
Public Property Zip FLDCRDZIP As String 15
Public Property State FLDCRDSTATE As String 30
Public Property EmailAddress1 FLDCRDEMAIL1 As String 70
Public Property Phone1 FLDCRDPHONE1 As String 25
Public Property Phone2 FLDCRDPHONE2 As String 25
Public Property FaxNumber FLDCRDFAX1 As String 25
Public Property Phone1Ext FLDCRDPHNDESC1 As String 40
Public Property Phone2Ext FLDCRDPHNDESC2 As String 40
Public Property FaxNumberExt FLDCRDFAXDESC1 As String 15
Public Property SubContractCode FLDCRDSUBCODE As String 15
Public Property Birthday FLDCRDBIRTHDAY As DateTime N/A
Public Property Notes FLDCRDNOTES As String Unlimited
Public Property CreationDate FLDCRDCREATEDATE As DateTime N/A
Public Property CreatedByUser FLDCRDCREATEUSERID As String 20
Public Property LastUpdatedBy FLDCRDUPDATEUSERID As String 20

Config Class

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

Property Type Required Description
AppName String Yes Maximum 15 chars, string that best identifies your application.
DllFolder String Yes Exact path to the folder where RangerMSP API DLLs are located (CmtDbEng.dll and CmtDbQry.dll, usually "C:\RangerMSP\ThirdParty\UserDev").
DbFolder String Yes Exact path to the folder where RangerMSP database is located (usually "C:\RangerMSP\db").
InitCRMApiDll 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.
InitCRMQryDll Boolean 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(Of KeyValuePair(Of String, String)) No Not used, reserved for future use
RaiseExceptionIfDatabaseFieldTruncated Boolean 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 CRM.Application object is initialized, you can refer to this instance by writing: CRM.Application.instance().

Table below lists the CRM.Application properties.

Property Type Description
config Config Access to the CRM.Config object passed in CRM.Application.Initialize method.
CmtDateFormat String 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).
CmtDateSeparator String Separator between the date ranges, usually '/', '-' or '.'.
CmtTimeFormat String Global RangerMSP time format.
CmtIsTimeFormatAMPMInUse Boolean 12 hour or 24 hour time format.

Table below list the CRM.Application methods.

Access modifier Method Arguments Return value Description
Public Shared Function instance () Application Method that returns the singleton object. Use it to access all CRM.Application properties/methods.
Public Shared Sub Initialize (ByVal c As Config) Method that initializes the internal RangerMSP API DLLs. Must be the first call before using any other RangerMSP library calls.
Public Shared Sub 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 property FileAs (CRM.Account.FileAs). To this property corresponds one shared object instance of the CRM.CrmField class accessible through CRM.Account.Fields.FileAs. To the property LastName (CRM.Account.LastName), corresponds the shared object CRM.Account.Fields.LastName of type CRM.CrmField. And so on, for each property in each class.

Below is a table that lists the properties available in the CRM.CrmField class.

Property Type Description
Key String The internal database field key (as FLDCRDFULLNAME or FLDCRDLASTNAME, etc.)
Type String Internal database field type (as CHAR, MEMO, DOUBLE, TIMESTAMP, etc.)
Size Integer Maximum allowed length for the field data (applies to CHAR Type).
Label String Label for the field
Hint String
Name String
DefaultValue String Default value for the field
DisplaySymbol String 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
Console.Out.Write(charge.AdjustAmount.ToString() + CRM.Charge.Fields.AdjustAmount.DisplaySymbol)

ObjectQuery Class

CRM.ObjectQuery is a generics 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:

Dim ticketSearch As New CRM.ObjectQuery(Of CRM.Ticket)
'account is previously initialized
ticketSearch.AddCriteria(CRM.Ticket.Fields.AccountREC_ID, CRM.OperatorEnum.opEqual, account.AccountREC_ID)
ticketSearch.AddCriteria(CRM.Ticket.Fields.UpdateDate, CRM.OperatorEnum.opGreaterThanOrEqual, DateTime.Parse("01 Jan 2011"))
Dim tickets As List(Of CRM.Ticket) = ticketSearch.FetchObjects()
'tickets now contains all CRM.Ticket objects that satisfy the above criteria.

By default, CRM.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:

Dim accountSearch As New CRM.ObjectQuery(Of CRM.Account)(CRM.LinkEnum.linkOR)

accountSearch.AddCriteria(CRM.Account.Fields.City, CRM.OperatorEnum.opEqual, "New York")
accountSearch.AddCriteria(CRM.Account.Fields.City, CRM.OperatorEnum.opEqual, "Chicago")
Dim accounts As List(Of CRM.Account) = accountSearch.FetchObjects()
'accounts now contains all CRM.Account objects that satisfy any of 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 CRM.ObjectQuery.FetchObjects and the objects in the results will have only those fields populated.

Dim accountSearch As New CRM.ObjectQuery(Of CRM.Account)(CRM.LinkEnum.linkOR)

accountSearch.AddCriteria(CRM.Account.Fields.City, CRM.OperatorEnum.opEqual, "New York")
accountSearch.AddCriteria(CRM.Account.Fields.City, CRM.OperatorEnum.opEqual, "Chicago")
Dim accounts As List(Of CRM.Account) = accountSearch.FetchObjects(CRM.Account.Fields.AccountREC_ID.Key & "," & CRM.Account.Fields.City.Key)
'CRM.Account objects in the accounts list now contain only the AccountREC_ID and City fields.

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

Access modifier Method Arguments Return value Description
Public Sub AddCriteria (ByVal sField As String, ByVal opEnum As OperatorEnum, ByVal sValue As String) 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 Sub AddCriteria (ByVal field As CrmField, ByVal opEnum As OperatorEnum, ByVal sValue As String) 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 (System.String) to search for. This variation (or the one variations with the System.DateTime or System.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 Sub AddCriteria (ByVal field As CrmField, ByVal opEnum As OperatorEnum, ByVal dtValue As DateTime) 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 (System.DateTime) to search for. Use this variation to search in fields that are of DateTime type.

Public Sub AddCriteria (ByVal field As CrmField, ByVal opEnum As OperatorEnum, ByVal nValue As Integer) 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 (System.Integer) to search for. Use this variation to search in fields that are of Integer type.

Public Sub AddCriteria (ByVal field As CrmField, ByVal opEnum As OperatorEnum, ByVal nValue As Double) 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 (System.Double) to search for. Use this variation to search in fields that are of Double type.

Public Sub AddSortExpression (ByVal sField As String, ByVal sortEnum As SortDirectionEnum) 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 Sub AddSortExpression (ByVal field As CrmField, ByVal sortEnum As SortDirectionEnum) 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 Function FetchObjects () As List(Of T) Executes the constructed query and returns a list of objects (of type T where T 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:

Dim config As New CRM.Config
config.AppName = "VB.NET 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)

Dim account As New CRM.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