Skip to content

Instantly share code, notes, and snippets.

View wvpv's full-sized avatar

Adam Spriggs wvpv

View GitHub Profile
@ojmccall
ojmccall / S3 trigger extended.py
Created August 18, 2022 06:23
Lambda to trigger SFMC import from S3
View S3 trigger extended.py
import json
import urllib.parse
import boto3
import requests
client_id = "client id here "
client_secret = "client secret here"
baseURL = "unique url string here"
automationURL = f"https://{baseURL}.rest.marketingcloudapis.com/automation/v1/automations/trigger"
View SSJS Automation Error Details
<script runat="server">
Platform.Load("Core", "1");
/* ======================================================= */
/* ======================== Config ======================= */
var authurl = "authmarketingcloudapiscom/"; //Get this from Setup
var client_id = "xxxxxxxxxxxxxxxxx"; //Get this from Setup
var client_secret = "yyyyyyyyyyyyyyy"; //Get this from Setup
var slackwebhook = "zzzzzzzzzzzzzzzzzzzzz"; //Get this from Slack API
var gtm = 10; //This is your GMT modifier for your timezone
var notify = "@channel"; //use this to notify the channel or specific people
View Simple Message to Slack Channel using Webhook (SSJS)
<script runat="server">
Platform.Load("Core","1");
try{
var url = 'https://hooks.slack.com/services/xxxxxxxx/yyyyyyyyyyyy/zzzzzzzzzzzzzzzz';
var contentType = 'text/plain';
var payload = '{"text":"Now this is SSJS!"}';
var headerNames = [];
var headerValues = [];
var result = HTTP.Post(url, contentType, payload, headerNames, headerValues);
@camrobert
camrobert / DE_Count_Slack_API.sj
Created November 15, 2021 10:18
SFMC DE Record Count Slack API
View DE_Count_Slack_API.sj
/*
=======================================================
Title: SFMC DE Record Count Slack API
Author: Cameron Robert
-------------------------------------------------------
Instructions:
1: Create a Javascript Code Resource CloudPage
2: Paste the below code to the page
3: Use the Cloud Page URL as "Request URL" for a "Slash Commands" component in the Slack API Dashboard.
4: Save and Authorise your Slack app to a workspace/channel.
@jkaiser28
jkaiser28 / Create_DE-Query_PushAddressDataView.ssjs
Last active December 30, 2021 18:46 — forked from wvpv/sfmc-sql-pushaddress.sql
Query to pull PushAddress data
View Create_DE-Query_PushAddressDataView.ssjs
<script runat="server" language="javascript">
Platform.Load("core","1");
var name = "PushAddressDataView";
/*
Load this is a Cloud Page to create a data extension based on the _PushAddress Data View and a Query Activity to populate it.
JOIN to _Subscribers as follows:
_PushAddress.ContactID = _Subscribers.SubscriberID
*/
var deObj = {
@maciejjankowski
maciejjankowski / download table to excel csv.js
Last active December 30, 2021 18:47
download table to excel csv.js. Charset MUST be UTF-16LE - this is the only solution that worked with Excel on Mac
View download table to excel csv.js
function exportTableToCSV($table, filename) {
var $rows = $table.find('tr:has(td,th)'),
// Temporary delimiter characters unlikely to be typed by keyboard
// This is to avoid accidentally splitting the actual contents
tmpColDelim = String.fromCharCode(11), // vertical tab character
tmpRowDelim = String.fromCharCode(0), // null character
// actual delimiter characters for CSV format
@zlove
zlove / gist:3b9b6a611715ec3a8a60
Last active February 25, 2020 22:53
Preview WooCommerce Emails
View gist:3b9b6a611715ec3a8a60
<?php
/**
* Quick hack to preview WooCommerce e-mails.
* Based on drrobotnik's answer from Stack Overflow: http://stackoverflow.com/a/27072101/186136
*
* Add this to <yourtheme>/functions.php and then visit a url like:
* http://<site_url>/wp-admin/admin-ajax.php?action=previewemail
*
* @return null
*/