Skip to content

Instantly share code, notes, and snippets.

View jdeblank's full-sized avatar

Josh de Blank jdeblank

  • Melbourne, Australia
View GitHub Profile

Keybase proof

I hereby claim:

  • I am jdeblank on github.
  • I am jdeblank (https://keybase.io/jdeblank) on keybase.
  • I have a public key ASChluyyJ1zSPCm0RuQvN9LVAr-a2jvz6VKY5kXLNxXsoAo

To claim this, I am signing this object:

<script runat="server">
Platform.Load("core","1.1.5");
var prox = new Script.Util.WSProxy();
var de = {
CustomerKey: 'AA554FF4-B0FF-4F1E-ADA9-123123123',
Name: 'NewName'
};
var resp = prox.updateItem("DataExtension", de);
Write("<br>Response: " + resp.Results[0].StatusMessage);
</script>
<script runat="server">
Platform.Load("core","1.1.5");
var prox = new Script.Util.WSProxy();
var options = {SaveOptions: [{'PropertyName': '*', SaveAction: 'UpdateAdd'}]};
var email = 'test@email.com';
var subscriberkey = 'yourkey';
function unsub(mid, listid) {
prox.setClientId({ "ID": mid }); //This will switch BU contexts
var props = {
<script runat="server">
Platform.Load("core","1.1.5");
var prox = new Script.Util.WSProxy();
var action = "ClearData";
var props = {
CustomerKey: 'testDE123'
};
var opts = {};
var data = prox.performItem("DataExtension", props, action, opts);
<script runat="server">
Platform.Load("core","1.1.5");
var prox = new Script.Util.WSProxy();
var queryAllAccounts = true;
var cols = ["Client.ID","CustomerKey","ListName","ID"];
var filter = {
Property: "ListClassification",
SimpleOperator: "equals",
Value: "PublicationList"
@jdeblank
jdeblank / ssjs_SFDC_id_check.js
Last active May 6, 2019 01:36
Verify a SFDC ID or convert from 15 to 18 char SFDC ID using SSJS from within Salesforce Marketing Cloud
<script runat="server">
Platform.Load("core","1.1.5");
var id1 = "foobarba@email.com";
var id2 = "foobar";
var id3 = "0036F00001zNm0BQAS";
var lookup5bin = {
'00000':'A', '01000':'I', '10000':'Q', '11000':'Y',
@jdeblank
jdeblank / ssjs_wsproxy_updatePublist.js
Last active January 22, 2023 01:03
Use SSJS and WSProxy to add/update a subscriber status in Publication List within Salesforce Marketing Cloud
<script runat="server">
Platform.Load("core","1.1.1");
var subkey = "abc123";
var email = "foo@bar.com"
var prox = new Script.Util.WSProxy();
// Set specific BU context if required
// prox.setClientId({ "ID": 7279411 });
<script runat="server">
Platform.Load("core","1.1.1");
// Example of HTTP GET/POST to SFMC REST API to retrieve HTML of an email
try {
var authBaseUrl = 'https://abcd.auth.marketingcloudapis.com';
var authEndPoint = '/v1/requestToken';
var restBaseUrl = 'https://abcd.rest.marketingcloudapis.com';
<script runat="server">
Platform.Load("core","1.1.1");
/*
Example that handles JSON data POSTed to this page.
e.g '{"firstname":"Joe","lastname":"Bloggs"}'
*/
var jsonpost, jsondata;
<script runat="server">
var prox = new Script.Util.WSProxy();
var tsdKey = '123';
var EmailAddress = 'joe@email.com';
var tsd = {
TriggeredSendDefinition: {
CustomerKey: tsdKey