Skip to content

Instantly share code, notes, and snippets.

View CloudPage-exception-logging-ssjs.html
<script runat="server">
Platform.Load("Core","1.1.1");
try{
</script>
{{your script goes here}}
<script runat="server">
}catch(e){
var errorMsg = Stringify(e.message)
View CloudPage-exception-logging.html
<script runat="server">
Platform.Load("Core","1.1.1");
try{
</script>
{{your script goes here}}
<script runat="server">
}catch(e){
var errorMsg = Stringify(e.message)
View exception-try-catch.html
<script runat="server">
Platform.Load("Core","1.1.1");
try{
</script>
{{your script goes here}}
<script runat="server">
}catch(e){
Write("Oops, something went wrong!<br>Please contact info@email.com so we can help you finalize your request.");
View get-queries.js
function getQueries(objectType, cols) {
var prox = new Script.Util.WSProxy(),
objectType = "QueryDefinition",
cols = ["Name", "Description", "ObjectID", "DataExtensionTarget.Name", "DataExtensionTarget.CustomerKey"],
moreData = true,
reqID = null,
numItems = 0;
while (moreData) {
moreData = false;
var data = reqID == null ? prox.retrieve(objectType, cols) : prox.getNextBatch(objectType, reqID);
View get-imports.js
function getImports(objectType, cols) {
var prox = new Script.Util.WSProxy(),
objectType = "ImportDefinition",
cols = ["DestinationObject.ObjectID", "Description", "Name", "ObjectID"],
moreData = true,
reqID = null,
numItems = 0;
while (moreData) {
moreData = false;
var data = reqID == null ? prox.retrieve(objectType, cols) : prox.getNextBatch(objectType, reqID);
View wsproxy-import-query.html
<script runat="server">
Platform.Load("Core", "1");
try {
//initiate WSProxy
var prox = new Script.Util.WSProxy();
//initiate data extension
var targetDE = 'xxxxxxx-xxxxxxx-xxxxxxxxx'; //pass external key of the target DE
var logDE = DataExtension.Init(targetDE);
function getImports(objectType, cols) {
@zuzannamj
zuzannamj / de-inventory-with-data-sources.html
Last active May 14, 2020
Below code pulls all Import and Query activities from Automation Studio along with the names of target Data Extensions which get updated by those activities. See prerequisites in comments.
View de-inventory-with-data-sources.html
<!--–– Copyright © 2020 Zuzanna Jarczynska http://sfmarketing.cloud ––-->
<script runat="server">
Platform.Load("Core", "1");
var authEndpoint = 'https://mcxxxxxxxxxxxxxx.auth.marketingcloudapis.com/', //provide API endpoint
client_id = 'xxxxxxxxxxx', //pass Client ID
client_secret = 'xxxxxxxxxx'; //pass Client Secret
var targetDE = 'xxxx-xxxx-xxxx-xxxx-xxxxx'; //pass external key of the target DE
View simple-form-FEE.html
%%[
SET @Submit = RequestParameter("Submit")
IF @Submit != "Success" THEN
]%%
<h2>Email:</h2>
<form action="%%=RequestParameter('PAGEURL')=%%" method="GET">
<label for="email">Email address:</label>
<input type="email" id="email" name="email" required="yes">
<button type="submit" name="Submit" id="Submit" value="Success">Submit</button>
</form>
View fire-entry-event-full-script.html
%%[
SET @Submit = RequestParameter("Submit")
IF @Submit != "Success" THEN
]%%
<h2>Email:</h2>
<form action="%%=RequestParameter('PAGEURL')=%%" method="GET">
<label for="email">Email address:</label>
<input type="email" id="email" name="email" required="yes">
<button type="submit" name="Submit" id="Submit" value="Success">Submit</button>
</form>
View fire-entry-event-call.js
//make api call to inject contact to a journey
if (email != null && accessToken != null) {
var email = Request.GetQueryStringParameter("email");
var headerNames = ["Authorization"];
var headerValues = ["Bearer " + accessToken];
var jsonBody = {
"ContactKey": email,
"EventDefinitionKey": "APIEvent-xxxxxx", //provide journey EVENT DEFINITION KEY
"Data": {
"email_field": email
You can’t perform that action at this time.