Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Rachid Mamai MamaiRachid

🏠
Working from home
  • Paris
View GitHub Profile
View automation_monitoring_fullcode.js
<script runat='server'>
Platform.Load("Core","1");
var api = new Script.Util.WSProxy();
try {
/* Retreive Automations_Monitoring_List DE automations that need to be monitored */
var deCustKey = 'Automations_Monitoring_List';
var cols = ["AutomationName", "toBeMonitored"];
View automation_monitoring_2.js
/* Function to retrieve automation status */
function getAutomationStatus(automationName) {
var result = api.retrieve("Automation", ["Name","ProgramID","CustomerKey","Status"], {
Property: "Name",
SimpleOperator: "equals",
Value: automationName
});
var automation = result.Results[0];
var objectId = automation.ObjectID;
View automation_monitoring_1.js
Platform.Load("Core","1");
var api = new Script.Util.WSProxy();
try {
/* Retreive Automations_Monitoring_List DE automations that need to be monitored */
var deCustKey = 'Automations_Monitoring_List';
var cols = ["AutomationName", "toBeMonitored"];
View lightning_design_header.html
<!-- Header Start -->
<div class="slds-m-around_large">
<div class="slds-page-header">
<div class="slds-page-header__row">
<div class="slds-page-header__col-title">
<div class="slds-media">
<div class="slds-media__figure">
<span class="slds-icon_container slds-icon-standard-opportunity" title="opportunity">
<svg class="slds-icon slds-page-header__icon" aria-hidden="true">
<use xlink:href="/assets/icons/standard-sprite/svg/symbols.svg#opportunity"></use>
View automations_schedules.js
%%[
SET @MID = '50000XXXX'
SET @apiCreds = LOOKUP('REST_Credentials', 'apiCreds', 'MID', @MID)
SET @apiCreds = DecryptSymmetric(@apiCreds, 'aes', 'INT_PWD', @null, 'INT_SALT', @null, 'INT_IV', @null)
]%%
<!doctype html>
<html>
<head>
<link rel="stylesheet" href="https://cloud.actu.lamutuellegenerale.fr/salesforce-lightning-design-system.min.css" />
<style>
View table_cells.js
Write('<tr class="slds-hint-parent"><th data-label="Automation Name" scope="row"><div class="slds-truncate" title='+automationContent.entry[i].name+'>'+ automationContent.entry[i].name +'</div></td>');
Write('<th data-label="Description" scope="row"><div class="slds-truncate" title="'+automationDescription+'" >'+ automationDescription +'</div></td>');
Write('<th data-label="Status" scope="row"><div class="slds-truncate" title="'+automationScheduleObject.schedule.scheduleStatus+'" >'+ automationScheduleObject.schedule.scheduleStatus +'</div></td>');
Write('<th data-label="Schedule Frequency" scope="row"><div class="slds-truncate" title="'+scheduleFrequencySplitted+'" >'+ scheduleFrequencySplitted +'</div></td>');
Write('<th data-label="Schedule Days" scope="row"><div class="slds-truncate" title="'+scheduleDays+'" >'+ scheduleDays +'</div></td>');
Write('<th data-label="Schedule Hours" scope="row"><div class="slds-truncate" title="'+hoursSchedule+'" >'+ hoursSchedule +'</div></td>');
Write('</tr>');
View lightning_table.html
<table class="slds-table slds-table_cell-buffer slds-table_bordered slds-table_striped slds-table_col-bordered slds-max-medium-table_stacked-horizontal slds-table_fixed-layout">
<thead>
<tr class="slds-line-height_reset">
<th class="" scope="col">
<div class="slds-truncate" title="Automation Name">Automation Name</div>
</th>
<th class="" scope="col">
<div class="slds-truncate" title="Description">Description</div>
</th>
<th class="" scope="col">
View automation_v1_automations_endpoint_response.js
{
"id": "d057f44c-9333-4154-999c-XXXXXXXX",
"name": "JB_DIXXXXX",
"description": "",
"key": "ea66db19-de12-41be-1dd4-940XXXXXX",
"typeId": 1,
"type": "scheduled",
"statusId": 6,
"status": "Scheduled",
"categoryId": 486,
View automation_v1_automations REST API Call & Parsing schedules.js
try {
automations = HTTP.Get(url, headerNames, headerValues);
automationContent = Platform.Function.ParseJSON(Platform.Function.ParseJSON(Stringify(automations)).Content);
// loop through all results
if(automationContent.entry.length > 0 && automationContent.entry.length !== null) {
for (i = 0; i < automationContent.entry.length; i++) {
automationDescription = automationContent.entry[i].description;
/* Getting schedule */
if(Platform.Function.ParseJSON(automationContent.entry[i].id) !== "" && Platform.Function.ParseJSON(automationContent.entry[i].id) !== null) {
View legacy_automation_endpoint_call.js
<script runat="server">
Platform.Load("Core","1.1.1");
/* The number of autoamtions we want to pull */
var automationsCount = 25;
url = tenantURL + ".rest.marketingcloudapis.com/legacy/v1/beta/automations/automation/definition/?$top="+ automationsCount +"&$skip=0&$sort=lastRunTime%20desc";
var headerNames = ["Authorization"];
var headerValues = ["Bearer " + accessToken];
var automations, automationContent, automationDescription;