Skip to content

Instantly share code, notes, and snippets.

View katydorjee's full-sized avatar
🤩

Karma Tsering Dorjee katydorjee

🤩
View GitHub Profile
@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",
@katydorjee
katydorjee / Get Data Extension Total Row Count.js
Created August 8, 2023 01:53
Get Data Extension Total Row Count
function getDataExtensionRowCount(DE_Name) {
if (DE_Name == '' || DE_Name == null) {
return null;
} else {
var ampscriptCodeLine = '%' + '%[SET @dataExtensionRowCount = DataExtensionRowCount("' + DE_Name + '")]%' + '%';
Platform.Function.TreatAsContent(ampscriptCodeLine);
var dataExtensionRowCount = Platform.Variable.GetValue("@dataExtensionRowCount");
return DataExtensionRowCount(dataExtensionRowCount);
}
}
@katydorjee
katydorjee / Get all the Automations from Salesforce Marketing Cloud using SSJS.html
Last active July 17, 2023 01:30
Get all the Automations from Salesforce Marketing Cloud using SSJS
<html>
<head>
<style>
body, a, input, td, th {font-family:sans-serif; font-size:12px;}
table {
border-collapse: collapse;
width: 100%;
}
@katydorjee
katydorjee / Get Ramdom top 10 records from a table.sql
Created May 8, 2023 07:04
Get Ramdom top 10 records from a table
SELECT TOP 10 [Contact ID],
Email,
[Full Name],
[First Name],
[Last Name],
Mobile
FROM [Customer]
ORDER BY NEWID()

AD-XX: <TOPIC - short, concise summary>

  • Date: <DATE - when the decision was made>
  • Driver: <DRIVER - list a single person driving consenus and decision making>
  • Stakeholders: <STAKEHOLDERS - list all relevant stakeholders affected by this decision>
  • Status: [PROPOSED | DECIDED | SUPERSEDED]
  • Categories: <CATEGORIES - use a simple grouping to help organize the set of decisions (e.g. backend, payment, user management, ...)>
  • Outcome: <OUTCOME - once decided, provide a short summary of the decision outcome here>

Context

@katydorjee
katydorjee / Remove records from Publication list.js
Created March 29, 2023 00:31
Remove records from Publication list
<script runat="server" language="javascript">
Platform.Load("core","1.1.1");
var isDebug = true;
var deObj = DataExtension.Init("<Data Extension Name>");
var deObjRows = deObj.Rows.Retrieve();
var publicationListID = "<Publication List ID>";
var prox = new Script.Util.WSProxy();
try {
var pubListArrayStr = "[";
@katydorjee
katydorjee / AEST-AEDT to CST time difference.js
Last active August 7, 2023 12:16
AEST/AEDT to CST time difference
<script runat="server">
/*Author:K.T. Dorjee
Date:15/06/2022*/
Platform.Load("Core", "1");
var isDebug = false;
var currentDate = new Date();
/* Below commented lines are for testing */
/* var currentDate = new Date('12-Dec-2023'); */
/* var currentDate = new Date('12-Jun-2023'); */
try {
@katydorjee
katydorjee / auditevents.js
Created June 26, 2022 12:46 — forked from wvpv/auditevents.js
Mirror AuditEvent Data to a Data Extension
<script runat="server" language="JavaScript">
Platform.Load("core","1");
var debug = false;
// Mirrors AuditEvent REST Object data into a data extension
// - Audit Event Log must be configured in the account first -- Email Studio > Admin > Security Settings > Enable Audit Trail Data Collection: Yes
// - creates its own data extension
// - docs: https://developer.salesforce.com/docs/marketing/marketing-cloud/guide/getAuditEvents.html
// - defaults to the past 30 days of events