Skip to content

Instantly share code, notes, and snippets.

View wvpv's full-sized avatar

Adam Spriggs wvpv

View GitHub Profile
@wvpv
wvpv / sfmc-check-list-membership.amp
Last active May 9, 2022 16:07
SFMC Check Subscriber List Members
%%[
var @isASubscriber, @sk, @row, @status, @listID
set @isASubscriber = 0
/* ListID can be found in the List's Properties tab */
set @listID = "111111"
/* Retrieve the SubscriberKey/EmailAddress */
/* via URL Parameter: */
@wvpv
wvpv / sfmc-custom-preference-center-boilerplate.html
Last active July 15, 2024 21:58
SFMC Custom Preference Center Boilerplate
<script runat="server" language="JavaScript">
// src: https://gist.github.com/wvpv/19777e1167d6ac91e2e8
// demo: https://pub.s7.exacttarget.com/yo3hzpktgmu?qs=7145718410d87e2af4e5001112e1de43e2e457b69041ac21&mid=7203368
Platform.Load("core", "1");
var debug = true;
var request = {};
@wvpv
wvpv / sfmc-triggered-send-soap-request-envelope.xml
Created December 11, 2015 17:26
SFMC Triggered Send SOAP Request
<?xml version="1.0" encoding="UTF-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" xmlns:a="http://schemas.xmlsoap.org/ws/2004/08/addressing">
<s:Header>
<a:Action s:mustUnderstand="1">Create</a:Action>
<a:MessageID>urn:uuid:9037cc93-13f4-433b-b3f9-250ffa643ea8</a:MessageID>
<a:ReplyTo>
<a:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:Address>
</a:ReplyTo>
</s:Header>
<s:Body xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
@wvpv
wvpv / sfmc-retrieve-triggeredsenddefinition.amp
Created December 11, 2015 17:27
SFMC Retrieve TriggeredSendDefinition
%%[
var @ret, @filter, @status, @rr
Set @ret = CreateObject("RetrieveRequest")
SetObjectProperty(@ret,"ObjectType","TriggeredSendDefinition")
AddObjectArrayItem(@ret,"Properties","Name")
Set @filter = CreateObject("SimpleFilterPart")
SetObjectProperty(@filter,"Property","CustomerKey")
@wvpv
wvpv / sfmc-retrieve-triggeredsenddefinition.amp
Created December 11, 2015 17:27
SFMC Retrieve TriggeredSendDefinition
%%[
var @ret, @filter, @status, @rr
Set @ret = CreateObject("RetrieveRequest")
SetObjectProperty(@ret,"ObjectType","TriggeredSendDefinition")
AddObjectArrayItem(@ret,"Properties","Name")
Set @filter = CreateObject("SimpleFilterPart")
SetObjectProperty(@filter,"Property","CustomerKey")
@wvpv
wvpv / sfmc-lookup-data-extension-rows.js
Last active October 6, 2017 11:08
SFMC Lookup Data Extension Rows
<script runat="server">
Platform.Load("core", "1");
var birthdayDE = DataExtension.Init("birthdayDE");
var filter = {
Property: "EmailAddress",
SimpleOperator: "equals",
Value: "abc@gmail.com"
};
var data = birthdayDE.Rows.Retrieve(filter);
Write("<br>data.length: " + data.length);
@wvpv
wvpv / sfmc-dynamic-dataextension-column-headings.js
Created December 11, 2015 17:28
SFMC Dynamic DataExtension Column Headings
<script runat="server">
Platform.Load("Core","1");
var hidden_fields = "_CustomObjectKey,Lookup_Flag";
var DE = DataExtension.Init("DataExtensionName");
var data = DE.Rows.Lookup(["Lookup_Flag"], [1], 10, "LookupField");
if (data.length > 0) {
Write("<table border='1' cellpadding='2' cellspacing='3' style='border-collapse:collapse;'>");
Write("<tr>");
@wvpv
wvpv / sfmc-dataextensionobject-retrieve-soap-envelope.xml
Last active February 19, 2023 12:24
SFMC DataExtensionField Retrieve SOAP Envelope
<?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-ampscript-regex-match.amp
Created December 11, 2015 17:29
SFMC AMScript Regex Match
%%[
var @str1, @str1b, @str2, @str2b, @str3, @str3b, @str4, @str4b
set @str1 = "whee 1/2 whoop"
set @str1b = replace(@str1,regexmatch(@str1, "\s\w/\w\s" , 0 , "IgnoreCase"), " ")
set @str2 = "whee *derp* whoop"
set @str2b = replace(@str2,regexmatch(@str2, "\*\w+\*" , 0 , "IgnoreCase"), "")
set @str3 = "whee (whatev) whoop"
set @str3b = replace(@str3,regexmatch(@str3, "\s\(.+\)\s" , 0 , "IgnoreCase"), " ")
%%[ /* IIF() */
var @firstName, @intro
set @firstName = AttributeValue("firstName") /* returns blank if null */
set @intro = "Hello"
if not empty(@firstName) then
set @intro = concat(@intro, ", ", @firstName)
endif
set @intro = concat(@intro,"! Check out these deals")