Skip to content

Instantly share code, notes, and snippets.

Adam Spriggs wvpv

View GitHub Profile
@wvpv
wvpv / sfmc-ssjs-list-all-publicationlists.js
Created Mar 20, 2019
List all PublicationLists with SSJS
View sfmc-ssjs-list-all-publicationlists.js
<script type="text/javascript" runat="server">
Platform.Load("core", "1");
var allPublicationLists = getAllPublicationLists();
for (var i in allPublicationLists) {
Write("\n" + allPublicationLists[i]["ID"] + "|" +allPublicationLists[i]["Client"]["ID"] + "|" +allPublicationLists[i]["Name"]);
}
@wvpv
wvpv / sfmc-rest-trigger-multiple-emails.txt
Created Mar 12, 2019
Trigger multiple emails with REST
View sfmc-rest-trigger-multiple-emails.txt
POST /messaging/v1/messageDefinitionSends/key:YOURTSDEXTERNALKEY/sendBatch HTTP/1.1
Host: YOURENDPOINT.rest.marketingcloudapis.com
Authorization: Bearer YOURAUTHTOKEN
Content-Type: application/json
cache-control: no-cache
[
{
"To": {
"Address": "neo@example.com",
"SubscriberKey": "1111",
@wvpv
wvpv / sfmc-rest-token-request-oauth2.txt
Last active Mar 12, 2019
REST token request (OAuth 2.0)
View sfmc-rest-token-request-oauth2.txt
POST /v2/token HTTP/1.1
Host: YOURENDPOINT.auth.marketingcloudapis.com
Content-Type: application/json
cache-control: no-cache
{
"grant_type": "client_credentials",
"client_id": "YOURCLIENTID",
"client_secret": "YOURCLIENTSECRET",
"scope": "email_read email_write email_send data_extensions_read data_extensions_write",
"account_id": "YOURMID"
@wvpv
wvpv / sfmc-sql-clear-data-extension.sql
Created Jan 29, 2019
Clear a data extension with a SQL query
View sfmc-sql-clear-data-extension.sql
select
null as Emailaddress
where 0 = 1
/* action: overwrite */
View sfmc-sql-ranking-method1.sql
select
x.bounceCategory
, x.sendid
from (
select
b.bounceCategory
, b.sendid
, row_number() over (partition by b.bounceCategory order by newid()) ranking
from _bounce b
) x
View sfmc-sql-ranking-method2.sql
select top 1 with ties
b.bounceCategory
, b.sendid
from _bounce b
order by row_number() over (partition by b.bounceCategory order by newid())
/* list all of the bounce categories and return */
/* a random sendid/jobid associated with each one */
View zip_xyz_axis_calc.sql
select
zip
, cos(radians(latitude)) * cos(radians(longitude)) xaxis
, cos(radians(latitude)) * sin(radians(longitude)) yaxis
, sin(radians(latitude)) zaxis
from zip_axis
/* credit https://stackoverflow.com/a/2233208/812377 */
@wvpv
wvpv / sfmc-ampscript-one-click-unsubscribe.html
Created Aug 31, 2018
One-Click Unsubscribe AMPscript
View sfmc-ampscript-one-click-unsubscribe.html
%%[
var @debug
var @jid
var @listid
var @batchid
var @email
var @skey
var @reason
var @unsubscribeAll
View CNX18-ECAS-template.html
<div data-type="slot" data-key="init"></div>
<html>
<head>
<style>
body, a, input {font-family:sans-serif;}
</style>
<div data-type="slot" data-key="head"></div>
</head>
<body>
<div data-type="slot" data-key="body"></div>
@wvpv
wvpv / CNX18-ECAS-subscriberReferrals.amp
Created Jun 9, 2018
CNX18-ECAS-subscriberReferrals
View CNX18-ECAS-subscriberReferrals.amp
%%[
var @sk, @rows, @row, @rowCount, @i
set @sk = AttributeValue("_subscriberkey")
set @rows = LookupRows("SubscriberReferrals", "SubscriberKey", @sk)
set @rowCount = rowcount(@rows)
if @rowCount > 0 then
]%%
You can’t perform that action at this time.