Import Bulk options into Selection Field in Sage CRM

By | December 29, 2014

It is possible to add options to the selection field of Sage CRM by doing Field Level customization. But if one wants to add several options into the selection field, then it will become a cumbersome task to do. This task can be automated by doing little customizations in Sage CRM. In this blog post, we will be explaining the same with an example.
Tip: Please make sure that the Sage CRM database is properly backed up before performing below tasks.
New Stuff: Control Selection Lookup in Sage CRM
Consider a case where a user wants to add several cities into the Country field dropdown from table Country Codes of another database. You need to follow below steps for the same.
1) Create JavaScript executable file and add below code snippet into the file.
var CRMUserName = ‘Admin’;
var CRMPassword = ”;
var CRMInstance = “CRM”           //Change this as per Sage CRM Instance Name
var eWare = CRM= new ActiveXObject(“eWare.”+ CRMInstance);
eWare.FastLogon = 3;                    //this prevents the Metadata from loading.
eWare.Logon(CRMUserName, CRMPassword);
var CountrySQLQuery = ” select * from CountryCodes (nolock) “;
var objCountrySQLQuery = CRM.CreateQueryObj(CountrySQLQuery,””);
while (!objCountrySQLQuery.eof)
objCustomCaption = CRM.CreateRecord(“custom_captions”);
objCustomCaption.Capt_FamilyType = “Choices”;
objCustomCaption.Capt_Family = “addr_country”;
objCustomCaption.Capt_Code = objCountrySQLQuery.FieldValue(“countrycodeid”);
objCustomCaption.Capt_US = objCountrySQLQuery.FieldValue(“countryname”);
objCountrySQLQuery = “”;
objCountrySQLQuery = null;
Here, Countrycodeid is the primary key on CountryCodes table and Countryname is the name of the country.
2) Once done, execute the executable file (Refer below blog post for executing the file).
Run the External JavaScript file in 64-bit Operating system
3) Once the script is executed, login into Sage CRM and do Metadata Refresh.
Now you can check the Country dropdown field. You will observe that all the Countries are listed in the dropdown.
You can apply above trick to any other dropdown field by modifying the above script.
You can also import bulk data in Sage CRM entity with above script. However, this will require corresponding modifications in the code.
Also Read:
1) Linked selection fields through client side scripting
2) Allowing multi selection search on a single select field
3) Change Search Select Advanced field to Selection in Self Service
4) User Select field Selection or Finder?
5) Sorting Country Selection