Skip to content

Instantly share code, notes, and snippets.

Avatar

Adam Spriggs wvpv

View GitHub Profile
@wvpv
wvpv / sfmc-update-salesforce-objects-with-ssjs.html
Last active May 4, 2023 10:01
Update Salesforce Objects with Server-Side JavaScript
View sfmc-update-salesforce-objects-with-ssjs.html
<script type="text/javascript" runat="server">
Platform.Load("core", "1");
var debug = 1;
// detect form submission
if (Request.Method == "POST") {
// retrieve the input values from the form payload
var subscriberKey = Request.GetFormField("subscriberKey");
@wvpv
wvpv / sfmc-asc-json.html
Last active April 25, 2023 20:48
Parse ASC JSON payload
View sfmc-asc-json.html
<html>
<head>
<style>
body, a, input {font-family:sans-serif;}
</style>
</head>
<body style="font-family:sans-serif">
%%=now()=%%
<h1>JSON Parse with GTL</h1>
%%[
@wvpv
wvpv / assets.js
Created April 4, 2023 16:48
Content Builder Asset Inventory
View assets.js
<script runat="server" language="JavaScript">
Platform.Load("core","1");
var debug = false;
try {
var prox = new Script.Util.WSProxy();
var startTime = Now();
var timeoutMilliseconds = 1500000; // 25 minutes
@wvpv
wvpv / auditevents.js
Last active April 4, 2023 14:06
Mirror AuditEvent Data to a Data Extension
View auditevents.js
<script runat="server" language="JavaScript">
Platform.Load("core","1");
var debug = false;
// Mirrors AuditEvent REST Object data into a data extension
// - Audit Event Log must be configured in the account first -- Email Studio > Admin > Security Settings > Enable Audit Trail Data Collection: Yes
// - creates its own data extension
// - docs: https://developer.salesforce.com/docs/marketing/marketing-cloud/guide/getAuditEvents.html
// - defaults to the past 30 days of events
@wvpv
wvpv / sfmc-deduplication-with-row-number-partition.sql
Created June 21, 2017 13:44
sfmc-deduplication-with-row-number-partition.sql
View sfmc-deduplication-with-row-number-partition.sql
select
x.emailaddress
, x.subscriberkey
from (
select
w.emailaddress
, w.subscriberkey
, w.insertDate
, row_number() over (partition by w.subscriberkey order by w.insertDate asc) ranking
from Welcome_Trigger w
@wvpv
wvpv / sfmc-dataextensionobject-retrieve-soap-envelope.xml
Last active February 19, 2023 12:24
SFMC DataExtensionField Retrieve SOAP Envelope
View sfmc-dataextensionobject-retrieve-soap-envelope.xml
<?xml version="1.0" encoding="UTF-8"?>
<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<s:Header>
<a:Action s:mustUnderstand="1">Retrieve</a:Action>
<a:MessageID>urn:uuid:e3f7fdfe-d225-47fb-a764-ad4f465fb724</a:MessageID>
<a:ReplyTo>
<a:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:Address>
</a:ReplyTo>
<a:To s:mustUnderstand="1">https://webservice.exacttarget.com/Service.asmx</a:To>
<o:Security xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" s:mustUnderstand="1">
@wvpv
wvpv / sfmc-sql-pushaddress.sql
Created December 10, 2019 14:59
Query to pull PushAddress data
View sfmc-sql-pushaddress.sql
select
_ContactID ContactID
, _DeviceID DeviceID
, _APID APID
, _Status Status
, _Source Source
, _SourceObjectId SourceObjectId
, _Platform Platform
, _PlatformVersion PlatformVersion
, _Alias Alias
@wvpv
wvpv / NotSent_Tracking.csv
Created January 17, 2023 16:18
Not Sent Tracking Schema
View NotSent_Tracking.csv
FieldName DataType Length Precision Scale PrimaryKey Required DefaultValue
ClientID Number TRUE TRUE
SendID Number TRUE TRUE
SubscriberKey Text 254 TRUE TRUE
EmailAddress EmailAddress FALSE FALSE
SubscriberID Number TRUE TRUE
ListID Number TRUE TRUE
EventDate Date TRUE TRUE
EventType Text 10 FALSE FALSE
BatchID Number TRUE TRUE
@wvpv
wvpv / CNX18-RASA-contact-delete.js
Last active January 18, 2023 14:10
CNX18-RASA-contact-delete
View CNX18-RASA-contact-delete.js
<script type="javascript" runat="server">
Platform.Load("core","1.1.5");
var DE = "Contacts_To_Delete";
var logDE = "Contacts_To_Delete_Log";
var log = DataExtension.Init(logDE);
var url = 'https://auth.exacttargetapis.com/v1/requestToken';
var contentType = 'application/json';