Skip to content

Instantly share code, notes, and snippets.

View katydorjee's full-sized avatar
🤩

Karma Tsering Dorjee katydorjee

🤩
View GitHub Profile
@katydorjee
katydorjee / UTC Date in AMPscript.html
Created June 23, 2024 21:24
UTC Date in AMPscript
%%[
var @systemDate, @utcDate
set @systemDate = Now()
set @utcDate = DateParse(@systemDate,1)
]%%
UTC Date: %%=v(@utcDate)=%%
@katydorjee
katydorjee / Remove subscriber from Auto Suppression List.js
Created May 16, 2024 04:46
Remove subscriber from Auto Suppression List
<script runat="server">
Platform.Load("Core","1.1.1");
var autoSuppressionExternalKey = "AutoSuppressionExternalKey";
var SubscriberstoRemoveFromAutoSuppressionList = "Data_Extension_ExternalKey";
var deleteRecords = DataExtension.Init(SubscriberstoRemoveFromAutoSuppressionList);
var data = deleteRecords.Rows.Retrieve();
for (var i=0; i < data.length; i++) {
var emailAddress = data[i].Email;
var deleteRow = Platform.Function.DeleteData(autoSuppressionExternalKey,['Email Address'],[emailAddress]);
@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)=%%