Skip to content

Instantly share code, notes, and snippets.

View wvpv's full-sized avatar

Adam Spriggs wvpv

View GitHub Profile
@wvpv
wvpv / sublime-text-search-replace-regex.txt
Last active March 25, 2024 18:52
Sublime Text Search/Replace RegEx Patterns
search: <(table|tbody|thead|tr|td|p|div)(.*?)>
replace: \n<\1\2>\n
search: <\/(table|tbody|thead|tr|td|p|div)>
replace: \n<\/\1>
@wvpv
wvpv / upsert-dataextension-object-soap.xml
Created March 8, 2024 20:45
Upsert DataExensionObject via SOAP
<?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">Create</a:Action>
<a:To s:mustUnderstand="1">{{soapEndpoint}}</a:To>
<fueloauth xmlns="http://exacttarget.com">{{accessToken}}</fueloauth>
</s:Header>
<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<UpdateRequest xmlns="http://exacttarget.com/wsdl/partnerAPI">
<Options>
@wvpv
wvpv / isdst.amp
Last active March 8, 2024 16:33
Check if date is DST with AMPscript
%%[
set @dateToCheck = "2023-10-25"
set @month = datepart(@dateToCheck, "M")
set @day = datepart(@dateToCheck, "D")
set @daysOfWeek = "SunMonTueWedThuFriSat"
set @dayOfWeekToFind = format(@dateToCheck,"ddd")
set @dayOfWeekNum = divide(add(indexof(@daysOfWeek,@dayOfWeekToFind),2),3)
@wvpv
wvpv / list-function.js
Created December 12, 2023 18:11
SSJS List Functions
<script runat="server" language="JavaScript">
Platform.Load("core","1");
var debug = true;
var prox = new Script.Util.WSProxy();
var mid = Platform.Function.AuthenticatedMemberID();
var publicationLists = getAllPublicationLists();
if (debug) {
select
createdDate
from [dataExtension]
where
dateadd(dd,datediff(dd,0,createdDate), 0) =
dateadd(d, -1, dateadd(m,datediff(m,0,dateadd(dd,datediff(dd,0,getDate()), 0))+1,0))
SELECT
x.emailAddress
, x.firstName
, x.zip
, x.store_zip
, x.store_phone
, x.ranking
, x.distance
from (
SELECT
@wvpv
wvpv / file-upload-cb.html
Last active October 31, 2023 16:12
Content Builder File Upload
<script runat="server" language="ampscript">
set @processingPageURL = "https://YOURTENANTHERE.pub.sfmc-content.com/YOURPATHHERE"
</script><!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1">
@wvpv
wvpv / file-upload-cb-processor.js
Created October 31, 2023 16:10
Content Builder File Upload Processor
<script runat="server" language="JavaScript">
Platform.Load("Core","1");
/* adapted from https://sfmarketing.cloud/2020/02/29/create-a-cloudpages-form-with-an-image-file-upload-option/ */
var results = {};
results.result = {};
results.debug = {};
results.error = {};
@wvpv
wvpv / sfmc-ampscript-one-click-unsubscribe.html
Last active October 6, 2023 03:42
One-Click Unsubscribe AMPscript
%%[
var @debug
var @jid
var @listid
var @batchid
var @email
var @skey
var @reason
var @unsubscribeAll
@wvpv
wvpv / sfmc-send-soap-object-retrieve-to-de.js
Last active September 1, 2023 19:23
Retrieve Send SOAP Object data and write to a Data Extension
<script runat="server">
Platform.Load("core","1");
var debug = false;
// Mirrors Send SOAP Object data into a data extension
// - creates its own data extension
// - without any date filters includes all sends from account inception
try {