Skip to content

Instantly share code, notes, and snippets.

Adam Spriggs wvpv

Block or report user

Report or block wvpv

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@wvpv
wvpv / SFMC-AMPscript-output-random-rows-from-a-data-extension.amp
Last active Nov 15, 2019
Output random rows from a data extension with AMPscript
View SFMC-AMPscript-output-random-rows-from-a-data-extension.amp
%%[
var @debug
set @debug = 1
var @rn
var @rows
var @rowCount
var @arr
var @max
@wvpv
wvpv / sfmc-update-salesforce-objects-with-ssjs.html
Created Jul 2, 2019
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 / asc.json
Created Jun 17, 2019
JSON ASC Sample
View asc.json
[
{
"sku":"123",
"name":"Square",
"url":"https://spmvs.com?sku=123"
},
{
"sku":"456",
"name":"Circle",
"url":"https://spmvs.com/?sku=456"
@wvpv
wvpv / asc.xml
Created Jun 17, 2019
ASC XML sample
View asc.xml
<?xml version="1.0" encoding="UTF-8"?>
<cart>
<items>
<item>
<sku><![CDATA[123]]></sku>
<name><![CDATA[Square]]></name>
<url><![CDATA[https://spmvs.com?sku=123]]></url>
</item>
<item>
<sku><![CDATA[456]]></sku>
View ExampleAJAX1-get-cities.js
<script type="text/javascript" runat="server">
Platform.Load("core", "1");
var state = Request.GetQueryStringParameter("state");
var citiesDE = DataExtension.Init("Cities");
var cities = citiesDE.Rows.Lookup(["state"], [state], 100);
cities = cities ? cities : "";
Write('{"results":' + Stringify(cities) + '}');
</script>
View ExampleAJAX1-get-cities.js
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Cities</title>
<script src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
</head>
<body>
<h4>Cities</h4>
View ExampleAJAX3-get-cities.js
<script type="text/javascript" runat="server">
Platform.Load("core", "1");
var authCookie = Platform.Request.GetCookieValue('auth');
if (authCookie) {
var state = Request.GetQueryStringParameter("state");
var citiesDE = DataExtension.Init("Cities");
var cities = citiesDE.Rows.Lookup(["state"], [state], 100);
View ExampleAJAX3.html
<script runat="server">
Platform.Load("core", "1");
var time = Platform.Function.Now();
var today = new Date(time);
var tomorrow = today.setDate(today.getDate() + 1);
Platform.Response.SetCookie("auth", Platform.Function.GUID(), tomorrow, true);
</script>
<!DOCTYPE html>
View ExampleAJAX2-get-cities
<script type="text/javascript" runat="server">
Platform.Load("core", "1");
var authIP = Platform.Request.GetRequestHeader('auth');
var thisIP = Platform.Request.ClientIP;
if (authIP == thisIP) {
var state = Request.GetQueryStringParameter("state");
View ExampleAJAX2
<script runat="server">
Platform.Load("core", "1");
var thisIP = Platform.Request.ClientIP;
</script>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
You can’t perform that action at this time.