Skip to content

Instantly share code, notes, and snippets.

View katydorjee's full-sized avatar
🤩

Karma Tsering Dorjee katydorjee

🤩
View GitHub Profile
@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:"[email protected]",FirstName:"Mary",LastName:"Gold"},
{EmailAddress:"[email protected]",FirstName:"Andrew",LastName:"Pink"},
{EmailAddress:"[email protected]",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": []
};
@katydorjee
katydorjee / Print SSJS variable in HTML using GTL.html
Last active November 13, 2023 19:54
Print SSJS variable in HTML using GTL
<script runat="server">
Platform.Load("Core","1.1.1");
var customerName = "Dorjee";
</script>
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
@katydorjee
katydorjee / Clear Data Extension.js
Created October 27, 2023 06:03
Clear Data Extension
function clearDataExtension(externalKey)
{
var prox = new Script.Util.WSProxy();
var action = "ClearData";
var props = { CustomerKey: externalKey };
var data = prox.performItem("DataExtension", props, action);
}
@katydorjee
katydorjee / execute SQL query in SSJS.js
Created September 20, 2023 01:33
Execute SQL query in SSJS.js
<script runat="server">
Platform.Load("Core","1.1.1");
try {
var qd = QueryDefinition.Init("SQL_Query_External_Key");
var campaignId = 'WINTER SALE'
var sql = "SELECT SubscriberKey, EmailAddress, FirstName, Status FROM MasterCustomer WHERE Status = '" + campaignId + "' FROM CampaignMaster";
var status = qd.Update({
Name : "SQL_Query_Name",