Skip to content

Instantly share code, notes, and snippets.

View katydorjee's full-sized avatar
🤩

Karma Tsering Dorjee katydorjee

🤩
View GitHub Profile
@katydorjee
katydorjee / A script to run an automation in a child BU from another child BU.html
Created March 1, 2024 00:35
A script to run an automation in a child BU from another child BU.
/*
##To initiate an automation from one child business unit (BU) to another or from a child BU to a parent BU.
#1. Run the following Script in the parent BU and obtain the ObjectID of the automation in the child BU.
*/
<script runat="server">
Platform.Load("core","1.1.1");
var prox = new Script.Util.WSProxy();
var MID = 10000000000;
@katydorjee
katydorjee / Select Auto-Suppression list using SQL Query.sql
Created February 29, 2024 10:51
Select Auto-Suppression list using SQL Query
SELECT status, [Date Added], [Email Address] from [Global Suppression List]
/* ------------
You can find the Auto-Suppression list in:
--Email Studio > Email > Admin > Send Management > Auto-Suppression list > [Your list name]
In above query [Global Suppression List] is an example of list created in Auto-Suppression list
*/
@katydorjee
katydorjee / Logging SSJS errors on the client side.js
Last active February 16, 2024 05:55
Logging SSJS errors on the client side.
<script runat="server">
var isDebug = true;
try {
var a = 1;
var b = "six";
var result = 1 / b;
if(isDebug)
Write('<script>console.log("result: ' + result + '")</script>');
@katydorjee
katydorjee / Insert Rows into Data Extension using SSJS.js
Created February 9, 2024 05:39
Insert Rows into Data Extension using SSJS
<script runat="server">
Platform.Load("Core","1.1.1");
try {
var rowsArr = [
{EmailAddress:"mgold@example.com1",FirstName:"Mary",LastName:"Gold"},
{EmailAddress:"apink@example.com1",FirstName:"Andrew",LastName:"Pink"},
{EmailAddress:"jsmith@example.com1",FirstName:"John",LastName:"Smith"}
];
@katydorjee
katydorjee / Ampscript print function.vb
Created February 7, 2024 01:27
Ampscript print function
%%[
SET @FirstName = 'Karma'
SET @LastName = 'Dorjee'
/* Use below line of code to print when debugging */
Output(Concat("My first name is ", @FirstName, "<br>"))
]%%
/* Use below line of code to print in the email message or SMS message or Push message or CloudPage */
@katydorjee
katydorjee / URL shortening with short.io using AMPScript.vb
Created January 13, 2024 11:34
URL shortening with short.io using AMPScript
var @headerKey, @headerVal, @payload, @response, @unsubscribeURL
set @headerKey = "authorization"
set @headerVal = "<MyApi_Token>"
set @myLongURL = "https://mylongUrlDomain.com/?q=some_lenghty_query_param_value"
set @payload = Concat('{
"allowDuplicates": false,
"domain": "my.customdomain.com",
@katydorjee
katydorjee / Lookup Data Extension - ServerSide Javascript.js
Created December 5, 2023 08:12
Lookup Data Extension - ServerSide Javascript
<script runat="server">
var subkey = '100'
var firstName = Platform.Function.Lookup('Data_Extension_Name','First_Name','SubscriberKey',subkey)
Write(firstName);
</script>
@katydorjee
katydorjee / Lookup Data Extension - Ampscript.vb
Created December 5, 2023 08:11
Lookup Data Extension - Ampscript
%%[
SET @subKey = '100'
SET @firstName = Lookup("Data_Extension_Name","First_Name","SubscriberKey", @SubsKey)
]%%
%%=v(@firstName)=%%
@katydorjee
katydorjee / SQL Query Email address pattern check.sql
Created November 13, 2023 09:44
SQL Query Email address pattern check
SELECT ID, FirstName, LastName, EmailAddress FROM CustomerMaster
WHERE EmailAddress NOT LIKE '%_@__%.__%'
@katydorjee
katydorjee / Upsert (add or update) Publication list.js
Created November 8, 2023 00:17
Upsert (add or update) Publication list
updatePublicationList(12345, "003X123456789", "Unsubscribed")
function updatePublicationList(listId, subscriberKey, status) {
/*
status = Unsubscribed or status = Active
*/
var subArr = {
"SubscriberKey": subscriberKey,
"Lists": []
};