Skip to content

Instantly share code, notes, and snippets.

Avatar

Josh de Blank jdeblank

  • Melbourne, Australia
View GitHub Profile
View Keybase.md

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:

View ssjs_wsproxy_updateDEName.js
<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>
View ssjs_wsproxy_PubList_RetrieveAndUpdate.js
<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 = {
View ssjs_wsproxy_ClearDEData.js
<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);
View ssjs_wsproxy_PubList_retrieve.js
<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
Verify a SFDC ID or convert from 15 to 18 char SFDC ID using SSJS from within Salesforce Marketing Cloud
View ssjs_SFDC_id_check.js
<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 Jan 22, 2023
Use SSJS and WSProxy to add/update a subscriber status in Publication List within Salesforce Marketing Cloud
View ssjs_wsproxy_updatePublist.js
<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 });
View ssjs_api_contentassets.js
<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';
View ssjs_GetPostData.js
<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;
View ssjs_wsproxy_TriggeredSend.js
<script runat="server">
var prox = new Script.Util.WSProxy();
var tsdKey = '123';
var EmailAddress = 'joe@email.com';
var tsd = {
TriggeredSendDefinition: {
CustomerKey: tsdKey