Skip to content

Instantly share code, notes, and snippets.

View NickDeckerDevs's full-sized avatar

nicholas decker NickDeckerDevs

View GitHub Profile
@NickDeckerDevs
NickDeckerDevs / workflow-year-month-since-date.js
Last active February 14, 2023 17:06
years months since date in javascript hubspot
// this will export out a 8 years 6 months since date
exports.main = async (event, callback) => {
// you can change these to yr, yrs, mo, mos if you would like
const terms = {
year: 'year',
yearPlural: 'years',
month: 'month',
monthPlural: 'months'
}
@NickDeckerDevs
NickDeckerDevs / workflow-associate-contacts-from-a-parent company-to-child companies.js
Last active January 14, 2023 20:12
HubSpot workflow to associate contacts from a parent company to child companies
const hubspot = require('@hubspot/api-client');
exports.main = async (event, callback) => {
// Created by Nathan De Long @ HubSpot, 1/14/2023
// This code is provided as-is, please test this code prior to using it in a live workflow in your environment.
// modified by nick decker @ deckerdevs 1/14/2023
// modified to unnest code and change to our coding standards, cleaning it up etc
// get the associated contacts for the parent company. note, trigger for this workflow is companies
@NickDeckerDevs
NickDeckerDevs / lottie-1-4-3.js
Created December 7, 2022 21:37
hold on to this for backup!
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self)["lottie-player"]={})}(this,(function(exports){"use strict";function _typeof(t){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}var REACT_ELEMENT_TYPE;function _jsx(t,e,r,i){REACT_ELEMENT_TYPE||(REACT_ELEMENT_TYPE="function"==typeof Symbol&&Symbol.for&&Symbol.for("react.element")||60103);var a=t&&t.defaultProps,s=arguments.length-3;if(e||0===s||(e={children:void 0}),1===s)e.children=i;else if(s>1){for(var n=new Array(s),o=0;o<s;o++)n[o]=arguments[o+3];e.children=n}if(e&&a)for(var h in a)void 0===e[h]&&(e[h]=a[h]);else e||(e=a||{});return{$$typeof:REACT_ELEMENT_TYPE,type:t,key:void 0===r?null:""+r,ref:null,props:e,_owner:null}}function _asyncIterator
@NickDeckerDevs
NickDeckerDevs / hubspot-better-assocation-loop.js
Created December 7, 2022 18:04
looping through deal => contact assocations in hubspot, then associating them
const hubspot = require('@hubspot/api-client');
exports.main = async (event, callback) => {
const hubspotClient = new hubspot.Client({
accessToken: process.env.custom_code_private_app
});
try {
@NickDeckerDevs
NickDeckerDevs / assocationapi-hubspot.js
Created December 7, 2022 17:52
workflow custom code in hubspot
const hubspot = require('@hubspot/api-client');
// adding async to this main function here
exports.main = async (event, callback) => {
// Instantiate a new HubSpot private app (secret)
const hubspotClient = new hubspot.Client({
accessToken: process.env.custom_code_private_app
});
@NickDeckerDevs
NickDeckerDevs / code.gs
Created December 6, 2022 16:28
google app script that scrapes a webpage (using column data) and then fills in content related to webpage
function onOpen() {
var ui = SpreadsheetApp.getUi();
ui.createMenu('Product Functions')
.addItem('Scrape Product SKUs', 'menuItem1')
.addSeparator()
.addSubMenu(ui.createMenu('Clean Up')
.addItem('Second item', 'menuItem2'))
.addToUi();
}
@NickDeckerDevs
NickDeckerDevs / list-hubspot-pages-to-csv.js
Created December 1, 2022 17:52
website pages / landing pages inhubspot, run in console after opening up to 100 pages, will be able to copy/paste out the data into vscode, then find/replace the VM..... text with blank
document.querySelectorAll('.content-table-row').forEach(item => {
let linktext = item.querySelector('a').innerText
let linkedit = item.querySelector('a').href
let linkurl = item.querySelector('.private-microcopy.is--text--help').innerText
let status = item.querySelector('[data-test-id="content-status-cell"]').innerText
console.log(`${linktext},https://${linkurl},${linkedit},${status}`)
})
@NickDeckerDevs
NickDeckerDevs / hubspot-gdpr-script.js
Created September 28, 2022 14:29
hubpsot gdpr api script
var _hsp = window._hsp = window._hsp || []
window.dataLayer = window.dataLayer || []
_hsp.push(['addPrivacyConsentListener', function(consent) {
// console.log('-------- [HubSpot website logging start] --------')
// console.log('analytics: ' + consent.categories.analytics)
// console.log('advertisement: ' + consent.categories.advertisement)
// console.log('functionality: ' + consent.categories.functionality)
// console.log('-------- [HubSpot website logging start] --------')
if(consent.categories.analytics) {
@NickDeckerDevs
NickDeckerDevs / hubl.html
Created September 25, 2022 00:19
hubl for blog tag and hubdb comparison -- using a made up object to represent the hubdb table
{% set tags_from_blog_post = ['Inspiration','Teambuilding'] %}
{# this set ebooks would actually be from your HUBDB call #}
{% set ebooks = [
{
"name": "fred",
"tags": "smile, Brains",
},
{
"name": "correct",
"tags": "Inspiration, Brains",
const hubspot = require('@hubspot/api-client');
exports.main = async (event, callback) => {
// not sure what you are doing here but putting this in a function seems better to me then the pasta
const handleQuote = (quoteObject) => {
// insert my cool code here that does stuff
}
// you should convert this to private app see: https://deckerdevs.com/blogs/hubspot-api-integrations-faqs-sunsetting-api-keys-for-private-apps