New API Helpers in CRM 7.0
Posted by Matt Rajkowski on March 18, 2014, 2:00 PM EDT
If you are importing data into the CRM, whether it's your first time using ConcourseSuite or it's an ongoing effort, the CRM API has several improvements to make it easier.
On the server-side, the CRM has a client access manager which an administrator must grant API access to. Once that's setup through the web UI, the import process can take place. Actually, the API allows for reading, writing, updating and deleting of CRM data, so there's much more you can do with it.
The example script I'll use for reference is a Java Beanshell (BSH) script. It is run from the command line and doesn't require compiling before executing. This makes the script file very easy to make changes to and test. The script must define the CRM libraries (.jar files) to use so that the client libraries can be used.
New in CRM 7 are several client-side API helpers including:
com.concursive.crm.api.client.helper.AccountHelper;
com.concursive.crm.api.client.helper.ContactHelper;
The AccountHelper has several methods which help to save Accounts, find relational values, create relational values and also setup and save custom fields:
class AccountHelper
retrieveOrgIdFromAccountNumber, deleteAccount, saveAccount,
retrieveAccountTypeIdFromValue, addTypeIdToAccount,
retrieveSegmentIdFromValue, saveSegment,
retrieveStageIdFromValue, saveStage,
retrieveRatingIdFromValue, saveRating, saveCustomFolderData,
retrieveAddressTypeIdFromValue,
retrieveEmailTypeIdFromValue, retrievePhoneTypeIdFromValue
These example screenshots show Mapping CSV columns to CRM fields, retrieving relational data from the CRM, saving CRM accounts and custom fields.
Mapping CSV to CRM
A function creates a map of the CSV column names to the CRM account, contact and custom fields.
Using Lookup Data from CRM
For values in the CRM which use a lookup table, the related integer Ids are discovered using the new helper methods. The helper will let you know if the value was found and there are methods to add new types to the CRM. In this example the rows of the CSV file are read in and mapped to a hashmap. The hashmap will be sent to the helper so that the proper client-to-server transactions can be made.
Saving the CSV data to CRM
In this example, the AccountHelper is used for saving the Account. Once the record id is obtained for the Account, some additional work can be done. Here custom fields and account types are added to the account. The contact data is also processed and saved to the CRM.
Summary
The Helper Classes make routine imports much easier to work with. No longer is there tedious XML to deal with.
You can find additional helpers in the com.concursive.crm.api.client.helper package. As of today there are AccountHelper, ContactHelper, OrderHelper, and ProductCatalogHelper.