Skip to content

Instantly share code, notes, and snippets.

@katydorjee
katydorjee / AMPscript and Server-Side JavaScript variable together.html
Created May 6, 2017 08:46
AMPscript and Server-Side JavaScript variable together
%%[
VAR @ProductName
SET @ProductName = "Mobile phone"
]%%
<script runat=server>
Platform.Load("Core","1");
//Get the Variable from AMPscript
@wvpv
wvpv / sfmc-asc-xml.html
Last active March 3, 2020 17:30
Parse ASC XML Payload
<html>
<head>
<style>
body, a, input {font-family:sans-serif;}
</style>
</head>
<body style="font-family:sans-serif">
%%=now()=%%
<h1>XML Parse with AMPScript</h1>
# Aliases
alias c="clear"
alias ll="ls -lah"
alias lz="ls -laZ" # include (selinux) security context in listing
alias cl="c && ll"
alias ..="cd .."
# Empty contents of files
empty() {
for arg in "$@"
@wvpv
wvpv / CNX18-RASA-contact-delete.js
Last active January 18, 2023 14:10
CNX18-RASA-contact-delete
<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';
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 */
<script runat="server">
Platform.Load("core","1.1.1");
try {
var de = DataExtension.Init('DE Name goes here');
var data = {
id: Request.GetFormField("id"),
FirstName: Request.GetFormField("firstname"),
Email: Request.GetFormField("email")
}
<script runat="server">
var skey = "abc123";
var prox = new Script.Util.WSProxy();
// query all BUs
var queryAllAccounts = true;
// set the attributes to be retrieved
// note Client.ID and not ClientID
var cols = ["Status","Client.ID"];
<script runat="server">
Platform.Load("core","1.1.1");
var listid = 1234;
var jobid = 567;
var batchid = 1;
var mids = {
BU1: 123456,
BU2: 123457,
<script runat="server">
Platform.Load("core","1.1.1");
var prox = new Script.Util.WSProxy();
// Need to retrieve the ObjectID for the Automation, which isn't available via the SFMC interface.
var cols = ["Name", "ProgramID", "IsActive"];
var filter = {
Property: "Name",
SimpleOperator: "equals",
<script runat="server">
var prox = new Script.Util.WSProxy();
var tsdKey = '123';
var EmailAddress = 'joe@email.com';
var tsd = {
TriggeredSendDefinition: {
CustomerKey: tsdKey