Difference between revisions of "SQL Organisation Import"

From Hornbill
Jump to navigation Jump to search
(Created page with "== About the Hornbill SQL Contact Import Utility == The utility provides a simple, safe and secure way to create contacts on the Hornbill platform by synchronizing with data h...")
 
 
(34 intermediate revisions by 3 users not shown)
Line 1: Line 1:
== About the Hornbill SQL Contact Import Utility ==
+
=About the SQL Organisation Import Utility=
The utility provides a simple, safe and secure way to create contacts on the Hornbill platform by synchronizing with data held in your Database.  The tool is designed to run behind your corporate firewall, connect to your database, query the required contact information, transform and load into the Hornbill instance.  The tool connects to the Hornbill instance in the cloud over HTTPS/SSL so as long as you have standard internet access then you should be able to use tool without the need to make any firewall configuration changes.  The tool supports both the initial bulk import as well as incremental adds and updates.  You can schedule the tool to run periodically to perform the import/update tasks as required.
 
  
== Open Source ==
+
The utility provides a quick and easy method of uploading and updating organisations from an external data source into Hornbill instance.
  
The SQL Contact Import Utility is provided open source under the [https://wiki.hornbill.com/index.php/The_Hornbill_Community_License_(HCL) Hornbill Community Licence] and can be found [https://github.com/hornbill/goDb2HcontactImport here] on GitHub
+
==Open Source==
  
== Installation Overview ==
+
The Hornbill SQL Organisation Import Utility is provided open source under the [https://wiki.hornbill.com/index.php/The_Hornbill_Community_License_(HCL) Hornbill Community Licence] and can be found [https://github.com/hornbill/goHornbillOrgImport Here] on GitHub
  
=== Windows Installation ===
+
==Installation Overview==
* Download the [https://github.com/hornbill/goDb2HcontactImport/releases/latest latest package] from GitHub
 
* Extract zip into a folder you would like the application to run from e.g. '''C:\Hornbill_Import\'''
 
* Open '''conf.json''' and add in the necessary configration
 
* Open Command Line Prompt as Administrator
 
* Change Directory to the folder with contactImport_x64.exe '''C:\Hornbill_Import\'''
 
* Run the command contactImport_x64.exe -dryrun=true
 
  
Change "x64" to "x86" depending on your architecture
+
===Windows Installation===
  
== Configuration Overview ==
+
* Download the [https://github.com/hornbill/goHornbillOrgImport/releases/latest ZIP archive] relevant to your OS and architecture. This contains the tool executable file, configuration file and license;
The following section will detail how to prepare the conf.json file to successfully import your Contact records.
+
* Extract the ZIP archive into a folder you would like the application to run from e.g. 'C:\organisation_import\'.
  
===Prerequisites===
 
Before importing any contact records into your Hornbill instance, the Organisation records must be created first. This then allows the contact import utility to associate each contact record to an Organisation record based on what is specified in the "Company" field. Details on how to create a Hornbill Organisation record can be found here: [[Organizations|'''external organization records''']]
 
  
Prior to configuring the .json file, it is advisable to read the following wiki page regarding [[Contacts|'''Hornbill Contact records''']] as it will provide some context to what this import will create.
+
=Configuration Overview=
  
To create a 64 bit ODBC connector you would need the Microsoft Access Database Engine which can be found as a 2010 Redistributable (https://www.microsoft.com/en-us/download/details.aspx?id=13255) or as an optional part of the Microsoft Office Suite
+
The configuration of this utility is managed through a JSON file (conf.json), which is supplied with each release:
<br>
 
<br>
 
  
===Completing the conf.json file===
+
<code>
A default configuration file is provided conf.json, if a configuration file is not specified as a command line argument then conf.json must exist.
+
     "APIKey": "your_api_key_here",
 
+
     "InstanceId": "your_instance_id_here",
    {
+
     "OrganisationAction": "Create/Update/Both",
     "APIKey": "", /* this is the API-key which is associated to a user in the Hornbill instance [1] */
 
     "InstanceId": "", /* your Hornbill instance name : not likely to change */
 
     "ContactAction": "Create", /* options : Create/Update/Both ; on what action to assign roles to a user */
 
    "AttachCustomerPortal": true, /* options : true/false ; whether contact is allowed to enter the customer portal */
 
    "CustomerPortalOrgView": true, /* options : true/false ; whether contact is allowed to view orgaisation calls in the customer portal */
 
    "CustomerPortalOrgViewRevoke": false, /* options : true/false ; whether the contact visibility to organisation calls in the customer portal is to be revoked */
 
    "UpdateContactStatus": false,
 
 
     "SQLConf": {
 
     "SQLConf": {
         "Driver": "csv",
+
         "Driver": "",
         "Server": "localhost",
+
         "Server": "",
         "Database": "CSV64",
+
         "Database": "",
         "UserName": "root",
+
         "UserName": "",
 
         "Password": "",
 
         "Password": "",
         "Port": 5002,
+
         "Port": 0,
        "ContactID": "FIELD1",  /* FieldID is the Hornbill field against which the record */
 
        "FieldID": "h_logon_id", /* (identified by the data contained in the ContactID field) is searched */
 
 
         "Encrypt": false,
 
         "Encrypt": false,
         "Query": "SELECT * FROM adbc.csv"
+
        "OrganizationName": "FIELD 1",
 +
         "Query": "SELECT <field_list> FROM <table_or_file>"
 
     },
 
     },
     "ContactMapping":{
+
     "OrganizationMapping":{
         "logon_id":"&#123;&#123;.FIELD1&#125;&#125;",
+
         "organization_name":"FIELD 1",
         "firstname":"&#123;&#123;.FIELD2&#125;&#125;",
+
         "address":"FIELD 2",
         "lastname":"&#123;&#123;.FIELD3&#125;&#125;",
+
         "city":"FIELD 3",
         "company":"&#123;&#123;.FIELD1&#125;&#125;",
+
         "state":"FIELD 4",
         "email_1":"&#123;&#123;.FIELD2&#125;&#125;",
+
         "postal_code":"FIELD 5",
         "email_2":"",
+
         "country":"FIELD 6",
         "tel_1":"&#123;&#123;.FIELD4&#125;&#125;",
+
        "industry":"FIELD 7",
         "tel_2":"",
+
        "phone_number":"FIELD 8",
         "jobtitle":"",
+
        "website":"FIELD 9",
         "description":"",
+
        "language":"FIELD 10",
         "notes":"",
+
         "custom_1":"FIELD 11",
         "country":"",
+
         "custom_2":"FIELD 12",
         "language":"",
+
         "custom_3":"FIELD 13",
         "private":"0",
+
         "custom_4":"FIELD 14",
         "rights":"0",
+
         "custom_5":"FIELD 15",
         "contact_status":"0"
+
         "custom_6":"FIELD 16",
 +
        "custom_7":"FIELD 17",
 +
         "custom_8":"FIELD 18",
 +
         "custom_9":"FIELD 19",
 +
         "custom_10":"FIELD 20",
 +
         "custom_11":"FIELD 21"
 
     }
 
     }
    }
+
</code>
# An API key is set up against a user within Hornbill (https://wiki.hornbill.com/index.php/API_keys). For example, if admin user is doing the import, enter the API Key for the admin user.
+
 
 +
 
 +
*'''APIKey''' - a Hornbill API key for a user account with the correct permissions to carry out all of the required API calls
 +
*'''InstanceId''' - Hornbil instance ID. You can get the instance ID from your URL used to access Hornbill: <nowiki>https://live.hornbill.com/your_instance_id/</nowiki>. This value is case sensitive.
 +
*'''OrganisationAction''' - one of the following values:
 +
**'''Create''' = Import will only create new organisations in your instance.
 +
***If the imported organisation already exists and this is set to "Create" then the organisation will not be created
 +
**'''Update''' = Import will only update existing organisations in your instance.
 +
***If the imported organisation does not exist and this is set to "Update" then the organisation will not be updated
 +
**'''Both''' = Import will create new organisations and update existing organisations in your instance.
 +
***If the imported organisation does not exist and this is set to "Both" then the organisation will be created
 +
***If the imported organisation does exist and this is set to "Both" then the organisation will be updated
 +
 
 +
 
 +
'''SQLConf'''
 +
 
 +
*'''Driver''' - the driver to use to connect to the database that holds the asset information. Needs to be one of the following:
 +
**'''mssql''' = Microsoft SQL Server (2005 or above)
 +
**'''mysql''' = MySQL Server 4.1+, MariaDB
 +
**'''mysql320''' = MySQL Server v3.2.0 to v4.0
 +
**'''csv''' = ODBC Data Source using MS Access Text Driver (*.txt, *.csv)
 +
**'''excel''' = ODBC Data Source using MS Excel Driver (*.xls, *.xlsx, *.xlsm, *.xlsb)
 +
 
 +
 
 +
When using mssql, mysql or mysql320 drivers, the '''Server''', '''Database''', '''UserName''', '''Password''' and '''Port''' parameters should be populated accordingly:
 +
*'''Server''' = the address of the SQL server (e.g. localhost)
 +
*'''Database''' = the name of the Database to connect to
 +
*'''UserName''' = this should be the SQL authentication Username to connect to the Database (if any, e.g. root)
 +
*'''Password''' = this should be the password for the above username (if any)
 +
*'''Port''' = the SQL port (e.g. 5002)
 +
 +
 
 +
When using csv or excel as a data source, the '''Database''' parameter should be populated accordingly:
 +
*'''Database''' = this should be populated with the  name of the ODBC connection (the name of the Data Source - DSN) on the PC that is running the tool
 +
 
 +
 
 +
In addition, when using any of the available drivers, the '''Encrypt''', '''OrganizationName''' and '''Query''' parameters should also be populated accordingly:
 +
*'''Query''' = this should be the SQL query to retrieve the organisation records (e.g. SELECT * FROM <datbase_table_or_file>)
 +
*'''OrganizationName''' = specify which field from your data source contains the organisation name
 +
*'''Encrypt''' = boolean value to specify whether the connection between the script and the database should be encrypted.
 +
 
 +
''NOTE'': There is a bug in SQL Server 2008 and below that causes the connection to fail if the connection is encrypted. Only set this to true if your SQL Server has been patched accordingly.
 +
 
 +
 
 +
'''OrganizationMapping'''
 +
 
 +
*Maps data from your data source into the generic Hornbill organisation record
 +
*Any value wrapped with "" will be populated with the corresponding response from the SQL Query and is treated literally as a written example.
 +
 
 +
=Set up ODBC Connector for CSV files=
 +
 
 +
To create a 64 bit ODBC connector for CSV files, you need to have '''Microsoft Access Text Driver''' installed. This comes with the Microsoft Access Database Engine which can be found as an [https://www.microsoft.com/en-us/download/details.aspx?id=13255 MS 2010 Redistributable] or as an optional part of the Microsoft Office Suite.
 +
 
 +
==Step 1==
  
===Configuring the ODBC Connector for CSV===
+
* in Windows menu open '''ODBC Data Sources''' app as Administrator (in Windows 10 you can type in "ODBC" in the search box on the taskbar to quickly find the ODBC Data Sources app)
 +
* in ODBC Data Sources app navigate to '''System DSN''' tab
 +
* click on '''Add''' button to "Create a New Data Source". In the list of drivers locate '''Microsoft Access Text Driver (*.txt, *.csv)'''. If this driver is not present in the list then you don't have Microsoft Access Database Engine installed. Please refer to the notes above to find out how to install it
 +
* click on '''Finish''' button to progress to the next step
  
[[File:ODBC CSV Settings 20170406.png]]
+
==Step 2==
  
== Command Line Parameters ==
+
* type in a name for your Data Source - this name will be used for the "Database" parameter in the JSON config file
 +
* set up the directory/folder where the CSV files are located:
 +
** when configuring the connector for the first time the '''Use Current Directory''' checkbox is selected by default. Unselect this checkbox to enable '''Select Directory''' button and click it. Navigate to the directory/folder where the CSV files are located. select the folder then click '''Ok''' button.
 +
** when editing an existing CSV connector the '''Use Current Directory''' checkbox should be unselected and '''Select Directory''' enabled. If the folder containing the CSV files is already displayed then there is no need to do anything in this step.
 +
* click on '''Options''' button to expand the current window
 +
* in the "Extensions List" select the '''*.csv''' option
 +
* click on '''Define Format''' button to progress to the next step
  
* file - Defaults to '''''conf.json''''' - Name of the Configuration file to load
+
==Step 3==
* dryrun - Defaults to '''''false''''' - Set to True and the XMLMC for Create and Update users will not be called and instead the XML will be dumped to the log file, this is to aid in debugging the initial connection information.
 
* concurrent - Defaults to `1` - Allows you to change the number of worker threads used to process the import, this can improve performance on slow import but using too many workers have a detriment to performance of your Hornbill instance.
 
* logprefix - add prefix to the log file
 
* version - outputs the tool version
 
* matchlike - defaults to '''''false''''' - Set to True if you want to mimick the post v1.0.3 behaviour which searches with LIKE instead of an exact match (eg "abc" would find "abc1" as the record to update between v1.0.3 and v1.4.0).
 
  
== Testing Overview ==
+
* if the directory/folder has been configured correctly in the previous step you should see the CSV file(s) in the '''Tables''' list. Select the file you need to use for the import.
If you run the application with the argument dryrun=true then no users will be created or updated, the XML used to create or update will be saved in the log file so you can ensure the LDAP mappings are correct before running the import.
+
* if you have column headings in your CSV file activate '''Column Name Header''' checkbox
 +
* amend '''Rows to Scan''' option depending on how many records you are importing. By default, this is set to 25, if you are importing more then it needs to be increased. It does not have to be an exact number but it needs to be sufficient to ensure all records from your file are retrieved
 +
* set '''Characters''' option to ANSI
 +
* on the left hand side there is a '''Columns''' list. By default, in the ODBC data source we are configuring the columns in the file are set to FIELD1, FIELD2, etc. You can leave them as they are but you need to ensure the columns in this list matches the columns in the CSV file or you can customise them. This does not affect the CSV file in any form, this is only for the ODBC Data Source configuration.
 +
**Note: when having column headers in the CSV file, using the '''Guess''' button will attempt to read the column headers and customise the columns in the list accordingly. This is not a failproof action (hence the name of the button) therefore you need to ensure the columns are configured correctly if the Guess button is used:
 +
*** '''Data Type''' = should always be '''Char''' unless there is a need to be another type
 +
*** '''Name''' = should be a valid name. Please note that on occasion invalid characters are introduced in the column name (e.g. ). You need to remove these characters and then click on '''Modify''' button to save the changes. Invalid characters in column name can cause the tool to fail to import the records.
 +
* click on '''Ok''' buttons all the way back to '''System DSN''' tab to finish the configuration
  
<code>
+
Note: when importing from multiple files, repeat this step for all the files you need to import
contactImport_x64.exe -dryrun=true
 
</code>
 
  
To actually do the import, use this:
+
If the configuration is complete then in the directory/folder selected during configuration there should now be a file named '''schema.ini'''. This file stores the configuration performed in the above steps. If this file is missing then the configuration was not completed successfully. This files stores the configuration for any file in the respective directory /folder therefore when defining a format for another file, the configuration is appended into this file rather than creating a separate schema file.
  
<code>
 
contactImport_x64.exe
 
</code>
 
  
== Example ==
+
== Execute ==
  
The following is an example of a successful import.
+
Command Line Parameters:
The CSV file can contain the contacts you wish to import
 
* Ensure the order is as shown in the example otherwise the data may populate incorrect fields
 
eg:
 
  
[[File:exampleCSV.JPG]]
+
* '''file''' - this should point to your JSON configuration file and by default looks for a file in the current working directory called conf.json. If this is present you don't need to have the parameter.
 +
* '''dryrun''' - if set to True the XMLMC for Create and Update organisations will not be called and instead the XML will be dumped to the log file, so you can ensure the data mappings are correct before running the import. Defaults to `false`.
  
Populate the API key with the Hornbill user's API Key, enter the instance id and username and password.  
+
'goOrganisationImport_x64.exe -file=conf.json'
* This is an example of what the Schema.ini file would look like
 
eg:
 
  
[[File:exampleSchema.JPG]]
 
  
* The example JSON file below shows the fields that match the CSV file
+
== Preparing to run the tool ==
  
eg:
+
* Open '''conf.json''' and add in the necessary configuration;
 +
* Open Command Line Prompt as Administrator;
 +
* Change directory to the folder with goOrganisationImport_x64 *.* executables 'C:\organisation_import
 +
** On 32 bit Windows PCs: goOrganisationImport_x86.exe
 +
** On 64 bit Windows PCs: goOrganisationImport_x64.exe
 +
* Follow all on-screen prompts, taking careful note of all prompts and messages provided.
  
[[File:JSON.JPG]]
 
  
* This is an example of the actual run using the command prompt AS ADMIN user
+
= API Key Rules =
eg:
+
This utility uses ([[API keys]]):
  
[[File:exampleImport.JPG]]
+
* data:entityAddRecord
 +
* data:entityBrowseRecords2
 +
* data:entityUpdateRecord
 +
* system:logMessage
  
== Logging Overview ==
+
=Troubleshooting=
  
All Logging output is saved in the "log" directory which can be found in the same location as the executable. The file name contains the date and time the import was run '''''SQL_Contact_Import_2015-11-06T14-26-13Z.log'''''
+
==Logging Overview==
  
==Trouble Shooting==
+
All Logging output is saved in the log directory in the same directory as the executable the file name contains the date and time the import was run 'SQL_Organization_Import_YYYYMMDDHHMMSS.log'
  
===Common Error Messages===
+
==Common Error Messages==
  
 
Below are some common errors that you may encounter in the log file and what they mean:
 
Below are some common errors that you may encounter in the log file and what they mean:
* ''' ''[ERROR] Error Decoding Configuration File:.....'' ''' - this will be typically due to a missing quote (") or comma (,) somewhere in the configuration file. This is where an online JSON viewer/validator can come in handy rather than trawling the conf file looking for that proverbial needle in a haystack.
+
* '' '''[ERROR] Error Decoding Configuration File:.....''' '' - this will be typically due to a missing quote (") or comma (,) somewhere in the configuration file. This is where an online JSON viewer/validator can come in handy rather than trawling the conf file looking for that proverbial needle in a haystack.
* ''' ''[ERROR] Get https://api.github.com/repos/hornbill/goDb2HcontactImport/tags: dial tcp xx.xx.xx.xx:xxx: ........'' ''' - this most likely indicates that you have a HTTP proxy server on your network between the host running the executable and your Hornbill API endpoint. Ensure the http_proxy environment variable is set (See the section on "HTTP Proxies" for more information) and that the proxy is configured to allow this communication.
 
* ''' ''[ERROR] Unable to Create User: Invalid value for parameter '[parameter name]': The text size provided (31 characters) is greater than the maximum allowable size of 20 characters for column [column name]'' ''' - the contents of your directory attribute exceed the maximum number of characters that can be placed in the Hornbill database column.
 
* ''' ''panic: runtime error: invalid memory address or nil pointer deference [recovered]...'' ''' - this error is suggesting an incorrectly specified attribute in the conf file. Where information is being obtained from a directory attribute, the attribute must be in the following format: ''<nowiki>{{.directoryAttributeName}}</nowiki>''
 
* ''' ''[ERROR] Unable to Create User: The value in element <userId> did not meet the required input pattern constraints. at location '/methodCall/params/userId' '' ''' - the user id contains characters that are not allowed. The User Id should be made up of alphanumeric characters. Full stops (.) and underscores (_) are also supported.
 
* ''' ''[ERROR] Unable to Update User: Invalid value for parameter '[parameter name]': Error setting value for column '[column name]'. bad lexical cast: source type value could not be interpreted as target'' ''' - this error is indicating that the contents of your directory attribute are in a format that is not compatible with the type of the Hornbill database column. For example, you will get this when trying to place text into a database field that is of type "INT" (accepts integer values only).
 
* ''' ''[ERROR] Unable to Load LDAP Attribute: '[LDAP attribute name]' For Input Param: '[Hornbill Parameter name]' '' ''' - When the import utility is unable to load a particular LDAP attribute, this means that the attribute field in your directory does not contain a value. This error will not prevent the user account being created or updated in Hornbill and can be considered more as a warning rather than an outright failure or problem.
 
  
 
=== Error Codes ===
 
=== Error Codes ===
Line 148: Line 189:
 
* '''102''' - Unable to Load Configuration File
 
* '''102''' - Unable to Load Configuration File
  
== HTTP Proxies ==
 
  
If you use a proxy for all of your internet traffic, the HTTP_PROXY Environment variable needs to be set. The https_proxy environment variable holds the hostname or IP address of your proxy server. It is a standard environment variable and like any such variable, the specific steps you use to set it depends on your operating system.
+
= HTTP Proxies =
 +
{{UtilityProxies}}
  
For windows machines, it can be set from the command line using the following:
+
=Scheduling Overview=
<br>
 
<code>
 
set HTTP_PROXY=HOST:PORT
 
</code>
 
<br>
 
Where "HOST" is the IP address or host name of your Proxy Server and "PORT" is the specific port number.
 
  
== Scheduling Overview ==
+
==Windows==
 +
You can schedule goHornbillOrgImport.exe to run with any optional command line argument from Windows Task Scheduler.
  
=== Windows ===
+
* Ensure the user account running the task has rights to goHornbillOrgImport.exe and the containing folder.
You can schedule .exe to run with any optional command line argument from Windows Task Scheduler.
+
* Make sure the Start In parameter contains the folder where goHornbillOrgImport.exe resides in otherwise it will not be able to pick up the correct path.
* Ensure the user account running the task has rights to ldap_import.exe and the containing folder.
 
* Make sure the Start In parameter contains the folder where the executable resides in, otherwise it will not be able to pick up the correct path. eg:
 
  
[[File:Ldap_import_schedule.png]]
 
  
 
[[Category:Integration]]
 
[[Category:Integration]]

Latest revision as of 15:15, 24 September 2021

About the SQL Organisation Import Utility

The utility provides a quick and easy method of uploading and updating organisations from an external data source into Hornbill instance.

Open Source

The Hornbill SQL Organisation Import Utility is provided open source under the Hornbill Community Licence and can be found Here on GitHub

Installation Overview

Windows Installation

  • Download the ZIP archive relevant to your OS and architecture. This contains the tool executable file, configuration file and license;
  • Extract the ZIP archive into a folder you would like the application to run from e.g. 'C:\organisation_import\'.


Configuration Overview

The configuration of this utility is managed through a JSON file (conf.json), which is supplied with each release:

   "APIKey": "your_api_key_here",
   "InstanceId": "your_instance_id_here",
   "OrganisationAction": "Create/Update/Both",
   "SQLConf": {
       "Driver": "",
       "Server": "",
       "Database": "",
       "UserName": "",
       "Password": "",
       "Port": 0,
       "Encrypt": false,
       "OrganizationName": "FIELD 1",
       "Query": "SELECT <field_list> FROM <table_or_file>"
   },
   "OrganizationMapping":{
       "organization_name":"FIELD 1",
       "address":"FIELD 2",
       "city":"FIELD 3",
       "state":"FIELD 4",
       "postal_code":"FIELD 5",
       "country":"FIELD 6",
       "industry":"FIELD 7",
       "phone_number":"FIELD 8",
       "website":"FIELD 9",
       "language":"FIELD 10",
       "custom_1":"FIELD 11",
       "custom_2":"FIELD 12",
       "custom_3":"FIELD 13",
       "custom_4":"FIELD 14",
       "custom_5":"FIELD 15",
       "custom_6":"FIELD 16",
       "custom_7":"FIELD 17",
       "custom_8":"FIELD 18",
       "custom_9":"FIELD 19",
       "custom_10":"FIELD 20",
       "custom_11":"FIELD 21"
   }


  • APIKey - a Hornbill API key for a user account with the correct permissions to carry out all of the required API calls
  • InstanceId - Hornbil instance ID. You can get the instance ID from your URL used to access Hornbill: https://live.hornbill.com/your_instance_id/. This value is case sensitive.
  • OrganisationAction - one of the following values:
    • Create = Import will only create new organisations in your instance.
      • If the imported organisation already exists and this is set to "Create" then the organisation will not be created
    • Update = Import will only update existing organisations in your instance.
      • If the imported organisation does not exist and this is set to "Update" then the organisation will not be updated
    • Both = Import will create new organisations and update existing organisations in your instance.
      • If the imported organisation does not exist and this is set to "Both" then the organisation will be created
      • If the imported organisation does exist and this is set to "Both" then the organisation will be updated


SQLConf

  • Driver - the driver to use to connect to the database that holds the asset information. Needs to be one of the following:
    • mssql = Microsoft SQL Server (2005 or above)
    • mysql = MySQL Server 4.1+, MariaDB
    • mysql320 = MySQL Server v3.2.0 to v4.0
    • csv = ODBC Data Source using MS Access Text Driver (*.txt, *.csv)
    • excel = ODBC Data Source using MS Excel Driver (*.xls, *.xlsx, *.xlsm, *.xlsb)


When using mssql, mysql or mysql320 drivers, the Server, Database, UserName, Password and Port parameters should be populated accordingly:

  • Server = the address of the SQL server (e.g. localhost)
  • Database = the name of the Database to connect to
  • UserName = this should be the SQL authentication Username to connect to the Database (if any, e.g. root)
  • Password = this should be the password for the above username (if any)
  • Port = the SQL port (e.g. 5002)


When using csv or excel as a data source, the Database parameter should be populated accordingly:

  • Database = this should be populated with the name of the ODBC connection (the name of the Data Source - DSN) on the PC that is running the tool


In addition, when using any of the available drivers, the Encrypt, OrganizationName and Query parameters should also be populated accordingly:

  • Query = this should be the SQL query to retrieve the organisation records (e.g. SELECT * FROM <datbase_table_or_file>)
  • OrganizationName = specify which field from your data source contains the organisation name
  • Encrypt = boolean value to specify whether the connection between the script and the database should be encrypted.

NOTE: There is a bug in SQL Server 2008 and below that causes the connection to fail if the connection is encrypted. Only set this to true if your SQL Server has been patched accordingly.


OrganizationMapping

  • Maps data from your data source into the generic Hornbill organisation record
  • Any value wrapped with "" will be populated with the corresponding response from the SQL Query and is treated literally as a written example.

Set up ODBC Connector for CSV files

To create a 64 bit ODBC connector for CSV files, you need to have Microsoft Access Text Driver installed. This comes with the Microsoft Access Database Engine which can be found as an MS 2010 Redistributable or as an optional part of the Microsoft Office Suite.

Step 1

  • in Windows menu open ODBC Data Sources app as Administrator (in Windows 10 you can type in "ODBC" in the search box on the taskbar to quickly find the ODBC Data Sources app)
  • in ODBC Data Sources app navigate to System DSN tab
  • click on Add button to "Create a New Data Source". In the list of drivers locate Microsoft Access Text Driver (*.txt, *.csv). If this driver is not present in the list then you don't have Microsoft Access Database Engine installed. Please refer to the notes above to find out how to install it
  • click on Finish button to progress to the next step

Step 2

  • type in a name for your Data Source - this name will be used for the "Database" parameter in the JSON config file
  • set up the directory/folder where the CSV files are located:
    • when configuring the connector for the first time the Use Current Directory checkbox is selected by default. Unselect this checkbox to enable Select Directory button and click it. Navigate to the directory/folder where the CSV files are located. select the folder then click Ok button.
    • when editing an existing CSV connector the Use Current Directory checkbox should be unselected and Select Directory enabled. If the folder containing the CSV files is already displayed then there is no need to do anything in this step.
  • click on Options button to expand the current window
  • in the "Extensions List" select the *.csv option
  • click on Define Format button to progress to the next step

Step 3

  • if the directory/folder has been configured correctly in the previous step you should see the CSV file(s) in the Tables list. Select the file you need to use for the import.
  • if you have column headings in your CSV file activate Column Name Header checkbox
  • amend Rows to Scan option depending on how many records you are importing. By default, this is set to 25, if you are importing more then it needs to be increased. It does not have to be an exact number but it needs to be sufficient to ensure all records from your file are retrieved
  • set Characters option to ANSI
  • on the left hand side there is a Columns list. By default, in the ODBC data source we are configuring the columns in the file are set to FIELD1, FIELD2, etc. You can leave them as they are but you need to ensure the columns in this list matches the columns in the CSV file or you can customise them. This does not affect the CSV file in any form, this is only for the ODBC Data Source configuration.
    • Note: when having column headers in the CSV file, using the Guess button will attempt to read the column headers and customise the columns in the list accordingly. This is not a failproof action (hence the name of the button) therefore you need to ensure the columns are configured correctly if the Guess button is used:
      • Data Type = should always be Char unless there is a need to be another type
      • Name = should be a valid name. Please note that on occasion invalid characters are introduced in the column name (e.g. ). You need to remove these characters and then click on Modify button to save the changes. Invalid characters in column name can cause the tool to fail to import the records.
  • click on Ok buttons all the way back to System DSN tab to finish the configuration

Note: when importing from multiple files, repeat this step for all the files you need to import

If the configuration is complete then in the directory/folder selected during configuration there should now be a file named schema.ini. This file stores the configuration performed in the above steps. If this file is missing then the configuration was not completed successfully. This files stores the configuration for any file in the respective directory /folder therefore when defining a format for another file, the configuration is appended into this file rather than creating a separate schema file.


Execute

Command Line Parameters:

  • file - this should point to your JSON configuration file and by default looks for a file in the current working directory called conf.json. If this is present you don't need to have the parameter.
  • dryrun - if set to True the XMLMC for Create and Update organisations will not be called and instead the XML will be dumped to the log file, so you can ensure the data mappings are correct before running the import. Defaults to `false`.

'goOrganisationImport_x64.exe -file=conf.json'


Preparing to run the tool

  • Open conf.json and add in the necessary configuration;
  • Open Command Line Prompt as Administrator;
  • Change directory to the folder with goOrganisationImport_x64 *.* executables 'C:\organisation_import
    • On 32 bit Windows PCs: goOrganisationImport_x86.exe
    • On 64 bit Windows PCs: goOrganisationImport_x64.exe
  • Follow all on-screen prompts, taking careful note of all prompts and messages provided.


API Key Rules

This utility uses (API keys):

  • data:entityAddRecord
  • data:entityBrowseRecords2
  • data:entityUpdateRecord
  • system:logMessage

Troubleshooting

Logging Overview

All Logging output is saved in the log directory in the same directory as the executable the file name contains the date and time the import was run 'SQL_Organization_Import_YYYYMMDDHHMMSS.log'

Common Error Messages

Below are some common errors that you may encounter in the log file and what they mean:

  • [ERROR] Error Decoding Configuration File:..... - this will be typically due to a missing quote (") or comma (,) somewhere in the configuration file. This is where an online JSON viewer/validator can come in handy rather than trawling the conf file looking for that proverbial needle in a haystack.

Error Codes

  • 100 - Unable to create log File
  • 101 - Unable to create log folder
  • 102 - Unable to Load Configuration File


HTTP Proxies

If you use a proxy for all of your internet traffic, the HTTP_PROXY and HTTPS_PROXY Environment variables need to be set. These environment variables hold the hostname or IP address of your proxy server. It is a standard environment variable and like any such variable, the specific steps you use to set it depends on your operating system.

For windows machines, it can be set from the command line using the following:
set HTTP_PROXY=HOST:PORT

set HTTPS_PROXY=HOST:PORT
Where "HOST" is the IP address or host name of your Proxy Server and "PORT" is the specific port number. IF you require a username and password to go through the proxy, the format for the setting is as follows:
set HTTP_PROXY=username:password@HOST:PORT

set HTTPS_PROXY=username:password@HOST:PORT

URLs to White List

Occasionally on top of setting the HTTP_PROXY variable the following URLs need to be white listed to allow access out to our network

Scheduling Overview

Windows

You can schedule goHornbillOrgImport.exe to run with any optional command line argument from Windows Task Scheduler.

  • Ensure the user account running the task has rights to goHornbillOrgImport.exe and the containing folder.
  • Make sure the Start In parameter contains the folder where goHornbillOrgImport.exe resides in otherwise it will not be able to pick up the correct path.