Core data setup
Section titled “Core data setup”To be updated into a scheduled job, this is a first/one time import for now. Create the SAML configuration and grab the id, pass it into this script:
var samlConfigFr = new FRecord("saml_configuration");if (!samlConfigFr.getRecord("2b44260190f94c1c918fb32ad0a75221")) { console.error("NOT FOUND");}
var OneLogin = require("auth/providers/OneLogin");var ol = new OneLogin();ol.importUsers(samlConfigFr);Companies
Section titled “Companies”HubSpot
Section titled “HubSpot”HubSpot is the authority on company data, below is the import script, be sure to set the value of the hapikey variable in the top of the script
var HTTPScriptable = require('core/HTTPScriptable');var DataLoader = require('ds.base/DataLoader');var hapikey = '<PUT HAPIKEY HERE>';var url = 'https://api.hubapi.com/crm/v3/objects/company/search?hapikey=' + hapikey;var portalId = '2962673';var hubspotSchema = 'f50e0def8f9d4902a53b390e9febb3f7';var loadFr = new FRecord('data_load');loadFr.insert();
var COUNTRIES = { "US": "503cf9b8eb5c4ff9978dd57139fe55bd"};
var dl = new DataLoader(loadFr).setTargetBucket('company').setDebug(true).setCorrelationSchema( hubspotSchema, 'hubspot_company_id', 'hubspot_last_loaded').setUpdateAllSlots(true).setAutoValidate(true).setCorrelationSlots(['name']);
var body = { filterGroups: [ { filters: [ { propertyName: 'lifecyclestage', operator: 'EQ', value: 'customer' } ] } ], sorts: [ { propertyName: "createdate", direction: "DESCENDING" } ], limit: 100, properties: ['name', 'lifecyclestage', 'website', 'address', 'address2', 'city', 'state', 'zip', 'country', 'phone']};
var hasNext = true;var http = new HTTPScriptable();http.setUrl(url);http.setHeader('Content-Type', 'application/json');while (hasNext == true) { http.setRequestBody(body, 'json'); var resp = http.post(); var respBody = resp.getResponseBody(); var bodyJson = JSON.parse(respBody); var companies = bodyJson.results; for (var i = 0; i < companies.length; i++) { var company = companies[i]; var properties = company.properties; dl.loadRecord({ name: properties.name, hubspot_company_id: company.id, hubspot_portal_id: portalId, address: properties.address, address_2: properties.address2, city: properties.city, state_province: properties.state, postal: properties.zip, country: COUNTRIES[properties.country], phone: properties.phone }); } if (bodyJson.hasOwnProperty('paging')) { body.after = bodyJson.paging.next.after; } else { hasNext = false; } System.sleep(1000);}N-central
Section titled “N-central”Setup the N-central data source under the CMDB navigation, uncheck the “Auto-validate” check boxes, and run it…
ConnectWise
Section titled “ConnectWise”Setup the ConnectWise data source, uncheck “Auto-validate company records” and uncheck “Update all company slots”, load the credential and populate values as appropriate and run it…