<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Mathes K on Medium]]></title>
        <description><![CDATA[Stories by Mathes K on Medium]]></description>
        <link>https://medium.com/@mathes.btech?source=rss-308614d5cc3f------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*imMrd039rUvcE5gdeonXjg.jpeg</url>
            <title>Stories by Mathes K on Medium</title>
            <link>https://medium.com/@mathes.btech?source=rss-308614d5cc3f------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 19:03:45 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mathes.btech/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[SFMC Journey Builder Code Activity]]></title>
            <link>https://medium.com/@mathes.btech/sfmc-journey-builder-code-activity-a711b475f6a2?source=rss-308614d5cc3f------2</link>
            <guid isPermaLink="false">https://medium.com/p/a711b475f6a2</guid>
            <category><![CDATA[salesforcemarketingcloud]]></category>
            <category><![CDATA[salesforce-marketing]]></category>
            <category><![CDATA[sfmc]]></category>
            <category><![CDATA[salesforce]]></category>
            <dc:creator><![CDATA[Mathes K]]></dc:creator>
            <pubDate>Thu, 02 Jul 2026 20:40:41 GMT</pubDate>
            <atom:updated>2026-07-02T20:40:41.160Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Use case:</strong> You want to make an API call from journey [OR] execute a custom SSJS script/ logic as part of your journey execution — how would you do that? <br><strong>Solution: </strong>Use Custom <em>Code Activity</em>.</p><p><strong>Steps to follow:</strong></p><ol><li>Create an installed package with ‘Journey Builder Activity’ component in it. Use the URL below.</li></ol><pre>URL: https://jb-code.pages.dev/</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*x_9Dge9vnQ_Toks3GDh5Pw.jpeg" /></figure><p>2. Navigate to Journey and you should see this icon</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9Lpgl96zd0aA9BiJ2qed9w.jpeg" /></figure><p>3. Drag and drop into Journey canvas.</p><p>Text box #1: Some sample ssjs scripts</p><p>Text box #2: All the fields available in entry source DE — searchable and can be inserted into your SSJS code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Z9I1A6Rz_85tRXLvHcURFQ.jpeg" /></figure><p><strong><em>Note: Do test this in a sandbox! Not for production — since the code is hosted in my personal cloudflare account. :) If you’d like to use it in production, reach out and I’d be happy to share the code.</em></strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a711b475f6a2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SF Personalization Simulator]]></title>
            <link>https://medium.com/@mathes.btech/sf-personalization-simulator-b063d726cefa?source=rss-308614d5cc3f------2</link>
            <guid isPermaLink="false">https://medium.com/p/b063d726cefa</guid>
            <category><![CDATA[salesforcepersonalization]]></category>
            <dc:creator><![CDATA[Mathes K]]></dc:creator>
            <pubDate>Fri, 17 Apr 2026 22:07:14 GMT</pubDate>
            <atom:updated>2026-04-17T22:07:14.862Z</atom:updated>
            <content:encoded><![CDATA[<p>Last week I attended Salesforce Personalization Partner learning enablement session by Max Ebb, where he walked us through the all new Salesforce Personalization and while doing so, he demo’d a ‘Simulator’ that he built to test Personalization Point.</p><p><em>It’s a Lightning Web Component that lets Salesforce Personalization developer to fire the Decisioning API directly from a Personalization Point record page without Postman.</em></p><p>It’s similar to the ‘Simulator’ in Marketing Cloud Personalization (Evergage), where you can select users and validate how your ‘Einstein Recipe’ performs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*c8ef6TwyRbZT4xytjZflkg.png" /><figcaption>Marketing Cloud Personalization Simulator</figcaption></figure><p>Like any sane person would do, I went ahead and asked Claude to create a similar one and here are the results.</p><ul><li>LWC component that can be placed in ‘Personalization Point’</li><li>Fires the Decisioning API via Apex callout with latest Device ID or random 16-digit id</li><li>Reads config (TSE URL, dataspace) from Custom Metadata</li><li>Auto-loads the Personalization Point API name from the current record</li><li>Renders results as a dynamic table and JSON view shows the full formatted raw API response</li><li>Image fields render as thumbnails; URL fields render as clickable links</li><li>Attributes block surfaces key-value response attributes (e.g. header text)</li></ul><p>And this is how it looks like.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DOdM7FSstvziTS4RW7xePg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NIDYcPqveccqX0cvuXB15A.png" /></figure><p>You can get the LWC component from here — <a href="https://github.com/matheswarwan/personalization-point-simulator-lwc">https://github.com/matheswarwan/personalization-point-simulator-lwc</a></p><p>I’d love to hear any feedbacks!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b063d726cefa" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SFMC SSJS Script — Get From Name & From Email from sender profiles]]></title>
            <link>https://medium.com/@mathes.btech/sfmc-ssjs-script-get-from-name-from-email-from-sender-profiles-eea973715a93?source=rss-308614d5cc3f------2</link>
            <guid isPermaLink="false">https://medium.com/p/eea973715a93</guid>
            <dc:creator><![CDATA[Mathes K]]></dc:creator>
            <pubDate>Mon, 12 May 2025 05:57:41 GMT</pubDate>
            <atom:updated>2025-05-12T05:57:41.659Z</atom:updated>
            <content:encoded><![CDATA[<h3>SFMC SSJS Script — Get From Name &amp; From Email from sender profiles</h3><p>Here’s a quick script to fetch all from name, from email addresses from sender profile — paste it in cloud pages and deploy it.</p><pre>&lt;script runat=&quot;server&quot;&gt;<br>    Platform.Load(&quot;core&quot;, &quot;1&quot;);<br>    <br>    var fromAddressFilter = &quot;&quot;; // Eg., @sap.example.com - filter based on a specific from email address<br><br>    var api = new Script.Util.WSProxy();<br> try {<br>        var cols = [ &quot;Name&quot;, &quot;CustomerKey&quot;, &quot;FromName&quot;, &quot;FromAddress&quot;, &quot;CreatedDate&quot;, &quot;ModifiedDate&quot;];<br>        var resp = api.retrieve(&quot;SenderProfile&quot; , cols);<br>        <br>        Write(&#39;&lt;table border=1&gt;&lt;tr&gt;&lt;td&gt;Name&lt;/td&gt;&lt;td&gt;From Name&lt;/td&gt;&lt;td&gt;From Email&lt;/td&gt;&lt;td&gt;Created Date&lt;/td&gt;&lt;td&gt;Modified Date&lt;/td&gt;&lt;/tr&gt;&#39;);<br><br>        if(resp.Results.length &gt; 0) {<br>            for(var r in resp.Results) {<br>                if(!fromAddressFilter || resp.Results[r].FromAddress.indexOf(fromAddressFilter) &gt; 0) {<br>                    Write(&#39;&lt;tr&gt;&lt;td&gt;&#39; + resp.Results[r].Name+ &#39;&lt;/td&gt;&lt;td&gt;&#39; <br>                        + resp.Results[r].FromName+ &#39;&lt;/td&gt;&lt;td&gt;&#39; <br>                        + resp.Results[r].FromAddress+ &#39;&lt;/td&gt;&lt;td&gt;&#39; <br>                        + resp.Results[r].CreatedDate+ &#39;&lt;/td&gt;&lt;td&gt;&#39; <br>                        + resp.Results[r].ModifiedDate + &#39;&lt;/td&gt;&lt;/tr&gt;&#39;);<br>                }<br>            }<br>        }<br><br>        Write(&#39;&lt;/table&gt;&#39;);<br><br> } catch(error) {<br>        Write(Stringify(error));<br>    }<br>&lt;/script&gt;</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=eea973715a93" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Under the hood: Automation Studio #1]]></title>
            <link>https://medium.com/@mathes.btech/under-the-hood-automation-studio-1-8182a71f12db?source=rss-308614d5cc3f------2</link>
            <guid isPermaLink="false">https://medium.com/p/8182a71f12db</guid>
            <dc:creator><![CDATA[Mathes K]]></dc:creator>
            <pubDate>Thu, 10 Oct 2024 17:38:00 GMT</pubDate>
            <atom:updated>2024-10-10T17:38:00.523Z</atom:updated>
            <content:encoded><![CDATA[<p>This is random notes of what I observe in the source/ network/ console tabs of automation studio. These are my observations and may not be accurate. :)</p><p>While Journey Builder has custom activities, why not automation studio?</p><p>Let’s look into what’s happening under the hood in automation studio, by going through inspect element → Network &amp; Source, and here are some of my observations.</p><ol><li><strong>workers</strong></li></ol><p><a href="https://mc.s13.marketingcloudapps.com/AutomationStudioFuel3/fuelapi/legacy/v1/beta/automations/workers/?_=1728576783303">https://mc.s13.marketingcloudapps.com/AutomationStudioFuel3/fuelapi/legacy/v1/beta/automations/workers/?_=1728576783303</a></p><p>This lists the available autoamtion studio activities and your permission levels. In example below, I get to know that I have access Create/ View/ Update/ Delete/ View Tracking/ Send permissions to SMS activity.</p><pre><br>    {<br>      &quot;key&quot;: &quot;33&quot;,<br>      &quot;name&quot;: &quot;SMS Activity&quot;,<br>      &quot;description&quot;: &quot;as-core-activityData-33-desc&quot;,<br>      &quot;categoryId&quot;: 33,<br>      &quot;goldDbName&quot;: &quot;as-core-activityData-33-name&quot;,<br>      &quot;goldDbDescription&quot;: &quot;as-core-activityData-33-desc&quot;,<br>      &quot;iconSmall&quot;: &quot;-160px 0&quot;,<br>      &quot;iconLarge&quot;: &quot;-240px -16px&quot;,<br>      &quot;url&quot;: &quot;&quot;,<br>      &quot;width&quot;: 0,<br>      &quot;height&quot;: 0,<br>      &quot;hasAccess&quot;: false,<br>      &quot;permissions&quot;: [<br>        {<br>          &quot;operationId&quot;: 0,<br>          &quot;hasPermission&quot;: true,<br>          &quot;permissionId&quot;: 161,<br>          &quot;permissionName&quot;: &quot;Create&quot;<br>        },<br>        {<br>          &quot;operationId&quot;: 1,<br>          &quot;hasPermission&quot;: true,<br>          &quot;permissionId&quot;: 162,<br>          &quot;permissionName&quot;: &quot;View&quot;<br>        },<br>        {<br>          &quot;operationId&quot;: 2,<br>          &quot;hasPermission&quot;: true,<br>          &quot;permissionId&quot;: 163,<br>          &quot;permissionName&quot;: &quot;Update&quot;<br>        },<br>        {<br>          &quot;operationId&quot;: 3,<br>          &quot;hasPermission&quot;: true,<br>          &quot;permissionId&quot;: 164,<br>          &quot;permissionName&quot;: &quot;Delete&quot;<br>        },<br>        {<br>          &quot;operationId&quot;: 25,<br>          &quot;hasPermission&quot;: true,<br>          &quot;permissionId&quot;: 165,<br>          &quot;permissionName&quot;: &quot;View Tracking&quot;<br>        },<br>        {<br>          &quot;operationId&quot;: 15,<br>          &quot;hasPermission&quot;: true,<br>          &quot;permissionId&quot;: 166,<br>          &quot;permissionName&quot;: &quot;Send&quot;<br>        }<br>      ]</pre><p>There were a total of 29 activities and these are some interesting ones I noticied —</p><ul><li>ELT — related to data fractory utility</li><li>Refresh Counts</li><li>Count Audience</li><li>Contacts BU Mapping Activity</li><li>Interaction Studio Decision Activity</li><li>Interaction Studio Event — haven’t seen this in automation studio before</li><li>Thunderhead Refresh Activity — probably old ones ?</li></ul><p><strong>2. ServerLogs</strong></p><p>When I look through the main.js file, I found post request to /serverlog.</p><p><a href="https://mc.s13.marketingcloudapps.com/AutomationStudioFuel3/js/main.js">https://mc.s13.marketingcloudapps.com/AutomationStudioFuel3/js/main.js</a></p><p>So, of course I had to try.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6xk3EYJ6xNk3NsbOJd6w8Q.png" /></figure><p>Probably some sf support person is going to scratch their head when/ if they see this log :D</p><p>While there is a POST endpoint, I am disappointed that there is no ‘GET’.</p><p>Also, found these functions and noting them for later reference.</p><pre>function escapeHTML(string) {<br>    var entityMap = {<br>        &#39;&amp;&#39;: &#39;&amp;amp;&#39;,<br>        &#39;&lt;&#39;: &#39;&amp;lt;&#39;,<br>        &#39;&gt;&#39;: &#39;&amp;gt;&#39;,<br>        &#39;&quot;&#39;: &#39;&amp;quot;&#39;,<br>        &quot;&#39;&quot;: &#39;&amp;#x27;&#39;<br>    };<br><br>    var entityRegex = new RegExp(&#39;[&#39; + _.keys(entityMap).join(&#39;&#39;) + &#39;]&#39;, &#39;g&#39;);<br><br>    if (string === null || typeof string === &#39;undefined&#39;) {<br>        return &#39;&#39;;<br>    } else {<br>        return (&#39;&#39; + string).replace(entityRegex, function(match) {<br>            return entityMap[match];<br>        });<br>    }<br>}<br><br><br>function validateEmailAddress(addressString) {<br>    // var emailValidationRegex = /^[A-Za-z0-9\._%\+\-]+@[A-Za-z0-9\.\-]+\.[A-Za-z]{2,}$/;<br>    var emailValidationRegexFromMT = /^([\w \!\#\$\%\&amp;\&#39;\*\-\/\=\?\^\`\{\|\}\~\.\+]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,20}|[0-9]{1,3})$/;<br>    return addressString.match( emailValidationRegexFromMT );<br>}</pre><p><strong>3. Backbone/ Marionette/ Lestache</strong></p><p>Custom Activities in Journey Builder &amp; Content block uses a client side js library — <strong><em>Postmonger</em></strong> — to communicate between the custom activity UI and the workflow/ content block.</p><p>For automation studio, it’s backbone, Marionette, Mustache.</p><ul><li>Backbone — for managing states &amp; syncing with server</li><li>Marionette — for displaying UI elements and contents</li><li>Lestache — it’s a custom wrapper of Mustache, with additional information</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gRweZCgn-iegBf80bI5CGA.png" /></figure><p>Each activities of Automation studio are created with mvc pattern.</p><ul><li>JS — summary.js — Uses Marionette and provides the template html when summary view of an activity is opened. Also, provides details on what data to display, what events / button clicks to monitor etc.,</li><li>Models — fetches data from server when UI is opened, sends updates to server when values are updated in UI</li></ul><p><strong>4. Internal APIs</strong></p><p>Couple of interesting internal APIs. To view them, open your network tab, reload the page and search for it.</p><p><strong><em>Aggregator — </em></strong>provides all the endpoints, permissions, internal features that are enabled etc.,</p><p><a href="https://mc.s13.exacttarget.com/cloud/fuelapi//platform-internal/v1/aggregator">https://mc.s13.exacttarget.com/cloud/fuelapi//platform-internal/v1/aggregator</a></p><p><strong><em>Business Rules — </em></strong>gets you all the business rules/ flags enabled for your specific account</p><p><em>internal/v1/access/businessrules</em></p><p><strong><em>feature flags — </em></strong>you might see some features that were disabled at tenant level. Eg., EnableSlackLink is disabled.</p><p><a href="https://mc.s13.marketingcloudapps.com/AutomationStudioFuel3/fuelapi/automation/v1/featureFlags/?_=1728581626873"><em>https://mc.s13.marketingcloudapps.com/AutomationStudioFuel3/fuelapi/automation/v1/featureFlags/</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8182a71f12db" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SFMC Query Studio — Minor Updates]]></title>
            <link>https://medium.com/@mathes.btech/sfmc-query-studio-minor-updates-94162f8781b6?source=rss-308614d5cc3f------2</link>
            <guid isPermaLink="false">https://medium.com/p/94162f8781b6</guid>
            <category><![CDATA[salesforcemarketingcloud]]></category>
            <category><![CDATA[sfmc]]></category>
            <dc:creator><![CDATA[Mathes K]]></dc:creator>
            <pubDate>Fri, 20 Sep 2024 16:39:00 GMT</pubDate>
            <atom:updated>2024-09-20T16:51:15.305Z</atom:updated>
            <content:encoded><![CDATA[<h3>SFMC Query Saver Extension — Minor Updates</h3><p>There are two minor updates in <strong>version 0.1.1</strong>.</p><ol><li>Launch the extension from Query Studio. Now you’ll see an launcher icon that takes you to the extension. <em>Recommended by Karim Soweid.</em></li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*70zXM_pb_TbUEGeBsR1PIA.png" /><figcaption>Launcher at bottom right corner</figcaption></figure><p>2. Export the saved queries to CSV. <em>Recommended by Renato Roque.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/618/1*fkXt-5HhmYjepB8WHlseGg.png" /><figcaption>New export option added</figcaption></figure><p>Note: Please update your extensions by going to chrome://extensions → Update and Re-enable it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/916/1*Bfl19uRwFDBVxxdqHI6CAQ.png" /><figcaption>Previous version — 0.1.0</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/904/1*_XMA9_AMu8xuFTQ2l9Of8g.png" /><figcaption>Click on Update</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/876/1*85moAaAA5tAHAOqx3Q8uJg.png" /><figcaption>Extension will be disabled, click on Enable button</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JIjWSSteQQ5o6Ehn5boCkw.png" /><figcaption>Click on Re-enable</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/836/1*8r4qzNdquR1IUHK_hSN_Gg.png" /><figcaption>version 0.1.1 is now active</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*70zXM_pb_TbUEGeBsR1PIA.png" /><figcaption>You would see the launcher at the bottom right corner</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=94162f8781b6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SFMC — AWS Lambda function to Delete multiple files from SFTP]]></title>
            <link>https://medium.com/@mathes.btech/sfmc-aws-lambda-function-to-delete-multiple-files-from-sftp-741a0bafcb91?source=rss-308614d5cc3f------2</link>
            <guid isPermaLink="false">https://medium.com/p/741a0bafcb91</guid>
            <dc:creator><![CDATA[Mathes K]]></dc:creator>
            <pubDate>Fri, 13 Sep 2024 17:58:05 GMT</pubDate>
            <atom:updated>2024-09-13T17:58:05.739Z</atom:updated>
            <content:encoded><![CDATA[<h3>SFMC — AWS Lambda function to Delete multiple files from SFTP</h3><p>I had this requirement to unzip email archival file that possibly contains thousands of eml files and once unzipped &amp; processing is done, delete all the eml files.</p><p>Since ‘Data Extract’ activity’s ‘Delete file from ET FTP or Safehouse’ will only allow us to <a href="https://salesforce.stackexchange.com/questions/216937/can-we-delete-file-from-sftp-import-folder-after-import-activity#comment328624_216937">delete ‘a’ file</a> (one file at a time), deleting thousands of files will not be possible.</p><p>One of the<strong> solution</strong> that I thought off is to write an api layer that can interact with SFTP.</p><p><strong>Why AWS Lambda? </strong><em>Though I’m used to &amp; fan of </em><strong><em>Heroku</em></strong><em>, deploying an App costs about $7 per month (even for devs?). In addition, I wanted to try something new — so, AWS (silly me).</em></p><p>Meat of the solution is this —</p><p>File Drop Automation → Unzip file → Process records (script) → Wait (cool down period) → <strong>Delete files (script)</strong>.</p><p>The <em>delete files </em>script would make an API call to below lambda function and on successful confirmation, will update the log.</p><h3>Node JS app</h3><p>Here’s the code used (<em>main.js</em>) and the full zip file to deploy is here — <a href="https://drive.google.com/file/d/1s1p7ygKFtAq446CI8PjF4gqOiDqAvuZ3/view?usp=sharing">function.zip</a></p><p><a href="https://drive.google.com/file/d/1s1p7ygKFtAq446CI8PjF4gqOiDqAvuZ3/view?usp=sharing">https://drive.google.com/file/d/1s1p7ygKFtAq446CI8PjF4gqOiDqAvuZ3/view</a></p><ul><li>Uses nodejs library <a href="https://www.npmjs.com/package/ssh2-sftp-client">ssh2-sftp-client</a> that supports get, put, delete, rename sftp operatoins</li><li>connects to sftp and using the request method GET / DELETE, performs the associated operation</li></ul><pre>import Client from &#39;ssh2-sftp-client&#39;;<br>import path from &#39;path&#39;;<br><br>export const handler = async (event) =&gt; {<br>  console.log(&#39;Init - v2...&#39;)<br>  const sftp = new Client();<br>  <br>  const method = event.requestContext.http.method;<br>  const queryParams = event.queryStringParameters || {};<br><br>  const { sftpHost, sftpUsername, sftpPassword, filetype, filename } = queryParams;<br>  const sftpPort = queryParams.sftpPort || 22; <br>  const directory = queryParams.directory || &#39;/Import&#39;; <br><br>  if (!sftpHost || !sftpUsername || !sftpPassword) {<br>    return {<br>      statusCode: 400,<br>      body: JSON.stringify({ message: &#39;Missing SFTP credentials&#39; }),<br>    };<br>  }<br><br>  if (!filetype &amp;&amp; !filename) {<br>    return {<br>      statusCode: 400,<br>      body: JSON.stringify({ message: &#39;Either filetype or filename must be provided&#39; }),<br>    };<br>  }<br><br>  const config = {<br>    host: sftpHost,<br>    port: sftpPort, <br>    username: sftpUsername,<br>    password: sftpPassword,<br>  };<br><br><br>  try {<br><br>    await sftp.connect(config);<br>    console.log(&#39;Connected to SFTP server&#39;);<br><br>    const files = await sftp.list(directory);<br>    console.log(&#39;Files: &#39; , files);<br><br>    const filterFiles = (files) =&gt; {<br>      if (filename) {<br>        return files.filter(file =&gt; file.name === filename);<br>      }<br>      if (filetype) {<br>        return files.filter(file =&gt; path.extname(file.name) === `.${filetype}`);<br>      }<br>      return [];<br>    };<br><br>    const filteredFiles = filterFiles(files);<br>    console.log(&#39;Filtered files: &#39; , filteredFiles);<br><br>    if (method === &#39;GET&#39;) {<br>      console.log(&#39;List of files : &#39; , filteredFiles.map(file =&gt; file.name));<br><br>      return {<br>        statusCode: 200,<br>        body: JSON.stringify({<br>          message: &#39;File list retrieved successfully&#39;,<br>          files: filteredFiles.map(file =&gt; file.name),<br>        }),<br>      };<br>    } else if (method === &#39;DELETE&#39;) {<br>      if (filteredFiles.length === 0) {<br>        return {<br>          statusCode: 404,<br>          body: JSON.stringify({<br>            message: &#39;No matching files found for deletion&#39;,<br>          }),<br>        };<br>      }<br><br>      for (const file of filteredFiles) {<br>        const remoteFilePath = `${directory}/${file.name}`;<br>        await sftp.delete(remoteFilePath);<br>        console.log(`Deleted file: ${file.name}`);<br>      }<br><br>      return {<br>        statusCode: 200,<br>        body: JSON.stringify({<br>          message: &#39;Files deleted successfully&#39;,<br>          deletedFiles: filteredFiles.map(file =&gt; file.name),<br>        }),<br>      };<br>    } // delete ends <br><br>    // default path<br>    return {<br>      statusCode: 400,<br>      body: JSON.stringify({ message: &#39;Unsupported HTTP method. Supported methods are GET / DELETE.&#39; }),<br>    };<br><br>  } catch (err) {<br>    console.error(`Error: ${err.message}`);<br>    return {<br>      statusCode: 500,<br>      body: JSON.stringify({<br>        message: `Error occurred: ${err.message}`,<br>      }),<br>    };<br>  } finally {<br>    // Close SFTP connection<br>    await sftp.end();<br>    console.log(&#39;SFTP connection closed&#39;);<br>  }<br>};</pre><h3>AWS Lambda function</h3><p>Here are the steps &amp; screenshots on implementing the lambda function.</p><p><em>For future references </em>— The necessary node js modules are downloaded into local under <em>node_modules</em> folder and the function code (main.js), along with <em>node_modules, package.json</em> are compressed together as <em>function.zip </em>and uploaded to aws.</p><p>Create AWS account, login and go to your dashboard.</p><p>In your dashboard, search for lambda service and click on Create Function</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8LEUcCwFluYs306z2pkfSg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5xbDRptLZQampOqTKCd9_w.png" /></figure><p>Once the function is created, under ‘<em>code</em>’ tab, upload the ‘<em>function.zip</em>’ file. This should auto-deploy and show the diagram as in <em>‘Function overview’</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*p_xUfh3Ptl-aOAFUJZCRdA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aiurCjtVCjun5srYebGSJQ.png" /></figure><p>Next, let’s link the lambda function to API — so that we can invoke the function using rest API.</p><p><em>Note — while you can use REST API method, I chose HTTP API because my app is not secured with oAuth and HTTP API is cost effective.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fyZhGg8V_zKYcp2zG3yVbg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6CRjgYu45RvzQgdD527feA.png" /></figure><p>Note down the <em>API endpoint</em>. Click on <em>API Gateway</em> and Create a new ‘<em>Stage</em>’ as <em>sftp.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7fVBfmhWPxQJw1FU0VuXhA.png" /></figure><p>Create 2x routes (GET &amp; DELETE) and attach the lambda function to it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*D8sT7bfXUst51INwYd7pNA.png" /></figure><p>Deploy the API</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dc3p-IQ_d8Jzy9rQGDg3ww.png" /></figure><p>And just like that, in few clicks, you’ve an API that’s up and running!!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oMtkfWYjlJF-3HkJtmPPTw.png" /></figure><p>To the URL that ends with /sftp, add /files and query parameters</p><blockquote>sftpHost — SFTP Host of your SFMC instance</blockquote><blockquote>sftpUsername — SFTP User Name</blockquote><blockquote>sftpPassword — SFTP Password</blockquote><blockquote>filetype — file extension — csv/ eml or any other extension</blockquote><blockquote>filename — exact file name</blockquote><blockquote>directory — /Import or /Export or any specific directory. Defaults to /Import</blockquote><blockquote>sftpPort — defaults to 22 if not provided</blockquote><blockquote>Note: use either filetype or filename.</blockquote><blockquote>Example URL —</blockquote><blockquote><a href="https://h8798nf2yh.execute-api.us-east-2.amazonaws.com/sftp/files?sftpHost=abc-def-ghi.ftp.marketingcloudops.com&amp;sftpUsername=1234567890&amp;sftpPassword=XYZ&amp;filetype=csv&amp;directory=/Export">https://h8798nf2yh.execute-api.us-east-2.amazonaws.com/sftp/files?sftpHost=abc-def-ghi.ftp.marketingcloudops.com&amp;sftpUsername=1234567890&amp;sftpPassword=XYZ&amp;filetype=csv&amp;directory=/Export</a></blockquote><p>Open this url (GET method)- which should return page like below. wohoo!!</p><p><em>(If there are errors, check the CloudWatch logs)</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/994/1*qLl3y2rsKVoqepURiuyqeQ.png" /></figure><p>To monitor logs, click on ‘View CloudWatch logs’</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EgLZJPdXEifUP0er-Cuilw.png" /></figure><p>Open Log Streams</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hOvx1E98GMrc0GDn_Zwsxw.png" /></figure><p>You’d see the logs</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*En5Kd9MYifhU83V9IBv8Mw.png" /></figure><p>Now, let’s try to delete all the csv files.</p><p>Using Talend API tester, set the method as ‘DELETE’ and filetype as ‘csv’</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1Wwqfo97q8OM0zZkfFYSlg.png" /></figure><p>and you should receive a success message. And, check your SFTP location</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jobPqFv9lKPS82OtW96fuQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/828/1*ri64az0x-eG2qvn9-Z1X-Q.jpeg" /><figcaption>Image curtsey : Mehmet Ozkaya</figcaption></figure><h4>Next steps —</h4><p>I’m going to work on expanding this to be able to perform all actions — including file upload, file download — when I get time/ need :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=741a0bafcb91" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SFMC Tips — Search / Extract all Automation Studio Activity (like Queries)]]></title>
            <link>https://medium.com/@mathes.btech/sfmc-tips-search-extract-all-automation-studio-activity-like-queries-35e0df4f84db?source=rss-308614d5cc3f------2</link>
            <guid isPermaLink="false">https://medium.com/p/35e0df4f84db</guid>
            <category><![CDATA[salesforcemarketingcloud]]></category>
            <category><![CDATA[saleforce-marketing-cloud]]></category>
            <category><![CDATA[sfmc]]></category>
            <dc:creator><![CDATA[Mathes K]]></dc:creator>
            <pubDate>Mon, 09 Sep 2024 19:47:06 GMT</pubDate>
            <atom:updated>2024-09-09T19:47:06.967Z</atom:updated>
            <content:encoded><![CDATA[<h3>SFMC Tips — Search / Extract all Automation Studio Activity (like Queries)</h3><p>Inspired from <a href="https://medium.com/@marketingcloudtips/how-to-retrieve-all-sql-queries-in-salesforce-marketing-cloud-using-rest-api-3d5872c2c1ed">Nobuyuki’s post</a> on this topic, here’s how I retrieve all SQL Queries (or other automation studio activities) from Salesforce Marketing Cloud.</p><p>It’s a three step process.</p><ol><li>Stay logged into SFMC instance &amp; navigate to correct BU</li><li>Identify the stack you’re from (look at the URL of your sfmc instance)</li><li>Replace your stack number in below URL (eg., mine is S12) and open it</li></ol><p>Once you open it, you’ll see the json. Let’s assume you opened the <em>v1/queries</em> endpoint — then you’ll see all SQL queries. And, if you have more than 500 rows, change the $page to 2, 3 etc., to find other</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*97Brlw3ELXHDEaW0o1RpZQ.png" /></figure><p><strong><em>Now, how do you convert this to json?</em></strong></p><p>Copy the contents of items array(from [{“… “}]) and use one of these methods</p><ol><li>Online Converter — <a href="https://data.page/json/csv">https://data.page/json/csv</a></li><li>Chrome extension — <a href="https://chromewebstore.google.com/detail/json-to-csv/afcnkcoempmipgnobjegmilfmglciipj">https://chromewebstore.google.com/detail/json-to-csv/afcnkcoempmipgnobjegmilfmglciipj</a></li><li>JS method — console.table(arr)</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*J_a5TYQ1mIjOUNa9lva01A.png" /></figure><h3><strong>Links —</strong></h3><ol><li><strong>Query Activities — </strong><a href="https://mc.s12.marketingcloudapps.com/AutomationStudioFuel3/fuelapi/automation/v1/queries/?$page=1&amp;$pageSize=500&amp;$orderBy=modifiedDate%20desc">https://mc.s12.marketingcloudapps.com/AutomationStudioFuel3/fuelapi/automation/v1/queries/?$page=1&amp;$pageSize=500&amp;$orderBy=modifiedDate%20desc</a></li><li><strong>Script Activities — </strong><a href="https://mc.s12.marketingcloudapps.com/AutomationStudioFuel3/fuelapi/automation/v1/scripts/?$page=1&amp;$pageSize=500&amp;$orderBy=modifiedDate%20desc">https://mc.s12.marketingcloudapps.com/AutomationStudioFuel3/fuelapi/automation/v1/scripts/?$page=1&amp;$pageSize=500&amp;$orderBy=modifiedDate%20desc</a></li><li><strong>Email Send Definitions — </strong><a href="https://mc.s12.marketingcloudapps.com/AutomationStudioFuel3/fuelapi/messaging-internal/v1/emailsenddefinition/?$page=1&amp;$pageSize=500&amp;$orderBy=modifiedDate%20desc">https://mc.s12.marketingcloudapps.com/AutomationStudioFuel3/fuelapi/messaging-internal/v1/emailsenddefinition/?$page=1&amp;$pageSize=500&amp;$orderBy=modifiedDate%20desc</a></li><li><strong>Import Activities — </strong><a href="https://mc.s12.marketingcloudapps.com/AutomationStudioFuel3/fuelapi/automation/v1/imports?$page=1&amp;$pageSize=500&amp;$orderBy=modifiedDate%20desc">https://mc.s12.marketingcloudapps.com/AutomationStudioFuel3/fuelapi/automation/v1/imports?$page=1&amp;$pageSize=500&amp;$orderBy=modifiedDate%20desc</a></li><li><strong>File Transfer Activities — </strong><a href="https://mc.s12.marketingcloudapps.com/AutomationStudioFuel3/fuelapi/automation/v1/filetransfers?$page=1&amp;$pageSize=500&amp;$orderBy=name%20asc">https://mc.s12.marketingcloudapps.com/AutomationStudioFuel3/fuelapi/automation/v1/filetransfers?$page=1&amp;$pageSize=500&amp;$orderBy=name%20asc</a></li><li><strong>Data Extract Activities — </strong><a href="https://mc.s12.marketingcloudapps.com/AutomationStudioFuel3/fuelapi/automation/v1/dataextracts?$page=1&amp;$pageSize=500&amp;$orderBy=modifiedDate%20desc">https://mc.s12.marketingcloudapps.com/AutomationStudioFuel3/fuelapi/automation/v1/dataextracts?$page=1&amp;$pageSize=500&amp;$orderBy=modifiedDate%20desc</a></li><li><strong>Data Filter Activities — </strong><a href="https://mc.s12.marketingcloudapps.com/AutomationStudioFuel3/fuelapi/automation/v1/filters/?$page=1&amp;$pageSize=500&amp;$orderBy=name%20desc">https://mc.s12.marketingcloudapps.com/AutomationStudioFuel3/fuelapi/automation/v1/filters/?$page=1&amp;$pageSize=500&amp;$orderBy=name%20desc</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=35e0df4f84db" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deep Search in SFMC Data Extension]]></title>
            <link>https://medium.com/@mathes.btech/deep-search-in-sfmc-data-extension-4a23055e1dce?source=rss-308614d5cc3f------2</link>
            <guid isPermaLink="false">https://medium.com/p/4a23055e1dce</guid>
            <category><![CDATA[saleforce-marketing-cloud]]></category>
            <category><![CDATA[sfmc]]></category>
            <dc:creator><![CDATA[Mathes K]]></dc:creator>
            <pubDate>Sat, 07 Sep 2024 19:56:42 GMT</pubDate>
            <atom:updated>2024-09-07T21:43:15.416Z</atom:updated>
            <content:encoded><![CDATA[<p>I was browsing reddit on Thrusday and <a href="https://www.reddit.com/r/marketingcloud/comments/1fa4ktw/search_if_a_value_exists_in_any_data_extension/">this</a> question caught my attention and I’ve had the same problem few times before but never had time to solve it, until yesterday.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PtW37h2H0aBeGxXoa7UZxA.png" /></figure><p>Spent a few hours and wrote / rewrote this code. You can find the full code and some instruction in <a href="https://github.com/matheswarwan/sfmc-search-in-all-de">github</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WtlHqEXmQKrHBJWF6vxksg.png" /><figcaption>Deep Search DE</figcaption></figure><h3><strong>Break down / Explanation</strong></h3><p>What does this code do?</p><ol><li>Gets the list of data extension from your SFMC instance (except log, QueryStudioResults, IGO &amp; PI related DEs — you don’t want to spend time searching a sendLog DE with 10m records do you?)</li><li>For each data extension, make a call to api endpoint to search for a given string. Once the response is received, make the next call — this is crucial so you don’t end up running parallel requests</li><li>The backend API does something interesting</li><li>First — it gets the list of fields from the DE and finds fields of type — Text, EmailAddress and Number (Note — I’m ignoring Boolean, Date, locale, decimal)</li><li>Second (the tricky part) — it creates a complex filter that includes all these files and uses a like operator search with % as prefix &amp; suffix</li><li>Last — perform the search, convert the result as HTML and return back to client side (in hindsight, I shouldn’t retruned this as json and used client side js library to convert to table — but for later day :) )</li></ol><h3><strong>Caution</strong></h3><p>This is a resource intensive process. If you’ve hundreds or thousands of data extensions, use it carefully or avoid using this method — the server might think that you’re DDOS’g it :)</p><h3>(Possible) Future improvements</h3><ol><li>Limit the # of data extension — eg., user should be able to specific the folder / list of data extensions to search from — this would reduce the search load</li><li>Support to additional field types</li></ol><p>I think this Friday was well spent — do share your thoughts/ feedback.</p><p>Git Link: <a href="https://github.com/matheswarwan/sfmc-search-in-all-de">https://github.com/matheswarwan/sfmc-search-in-all-de</a></p><p>Reddit Question: <a href="https://www.reddit.com/r/marketingcloud/comments/1fa4ktw/search_if_a_value_exists_in_any_data_extension/">https://www.reddit.com/r/marketingcloud/comments/1fa4ktw/search_if_a_value_exists_in_any_data_extension/</a></p><p><strong>Erratum: </strong>Removed <em>‘.. you might end up consuming a lot of super messages..’</em></p><p>Reason: <a href="https://medium.com/@marketingcloudtips">Nobuyuki</a> <a href="https://www.linkedin.com/feed/update/urn:li:activity:7238275034610384896?commentUrn=urn%3Ali%3Acomment%3A%28activity%3A7238275034610384896%2C7238298537170456577%29&amp;dashCommentUrn=urn%3Ali%3Afsd_comment%3A%287238298537170456577%2Curn%3Ali%3Aactivity%3A7238275034610384896%29">pointed</a> out that the API pages ‘does not’ consume / count towards super messages — so, we are good here. :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4a23055e1dce" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[CloudPage + SSJS — Refresh Filter Data Extension]]></title>
            <link>https://medium.com/@mathes.btech/cloudpage-ssjs-refresh-filter-data-extension-7b77ad3f590f?source=rss-308614d5cc3f------2</link>
            <guid isPermaLink="false">https://medium.com/p/7b77ad3f590f</guid>
            <category><![CDATA[salesforcemarketingcloud]]></category>
            <category><![CDATA[alpinejs]]></category>
            <category><![CDATA[landing-pages]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Mathes K]]></dc:creator>
            <pubDate>Mon, 01 Apr 2024 08:20:06 GMT</pubDate>
            <atom:updated>2024-04-01T08:20:06.977Z</atom:updated>
            <content:encoded><![CDATA[<h3>CloudPage + SSJS — Refresh Filter Data Extension</h3><p>Here’s a quick script — a landing page that displays all your available filtered data extensions and allows you to refresh them.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hNCsf8ONvH24gypkTu73hg.png" /></figure><p>Usually, a data filter is created, along with a filter activity that can be used in automation studio and an automation is configured to refresh the filtered data extension.</p><p>Problem statement — When you’ve 100s of filtered data extensions created that are used in different places, navigating through the folders, finding them and refreshing is a bit of a tedious task — thus wrote this small landing page with <a href="https://alpinejs.dev/">alpine.js</a>.</p><p>This landing page</p><ol><li>lists all available filtered data extensions</li><li>allows you to select one/ more filtered DEs</li><li>sends them to form handler page that refreshes the filtered DEs</li></ol><p>The script can be modified a bit and can be used in a script activity in automation studio.</p><p><strong>Index page</strong></p><pre>&lt;!DOCTYPE html&gt;<br>&lt;html lang=&quot;en&quot;&gt;<br>&lt;head&gt;<br>    &lt;meta charset=&quot;UTF-8&quot;&gt;<br>    &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot;&gt;<br>    &lt;title&gt;Refresh Filter Data Extension&lt;/title&gt;<br>    &lt;script src=&quot;//unpkg.com/alpinejs&quot; defer&gt;&lt;/script&gt;<br>    &lt;script src=&quot;https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js&quot; integrity=&quot;sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p&quot; crossorigin=&quot;anonymous&quot;&gt;&lt;/script&gt;<br>    &lt;link href=&quot;https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css&quot; rel=&quot;stylesheet&quot; integrity=&quot;sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3&quot; crossorigin=&quot;anonymous&quot;&gt;<br>    &lt;style&gt;<br>      .toast {<br>          visibility: hidden;<br>          min-width: 250px;<br>          margin-left: -125px;<br>          background-color: #333;<br>          color: #fff;<br>          text-align: center;<br>          border-radius: 2px;<br>          padding: 16px;<br>          position: fixed;<br>          z-index: 1;<br>          left: 50%;<br>          bottom: 30px;<br>          font-size: 17px;<br>      }<br><br>      .show {<br>          visibility: visible;<br>          -webkit-animation: fadein 0.5s, fadeout 0.5s 2.5s;<br>          animation: fadein 0.5s, fadeout 0.5s 2.5s;<br>      }<br><br>      @-webkit-keyframes fadein {<br>          from {bottom: 0; opacity: 0;}<br>          to {bottom: 30px; opacity: 1;}<br>      }<br><br>      @keyframes fadein {<br>          from {bottom: 0; opacity: 0;}<br>          to {bottom: 30px; opacity: 1;}<br>      }<br><br>      @-webkit-keyframes fadeout {<br>          from {bottom: 30px; opacity: 1;}<br>          to {bottom: 0; opacity: 0;}<br>      }<br><br>      @keyframes fadeout {<br>          from {bottom: 30px; opacity: 1;}<br>          to {bottom: 0; opacity: 0;}<br>      }<br>  &lt;/style&gt;<br>&lt;/head&gt;<br>&lt;body x-data=&quot;filterDE()&quot; x-init=&quot;init()&quot; class=&quot;container&quot;&gt;<br>  &lt;script runat=&quot;server&quot;&gt;<br>    Platform.Load(&quot;core&quot;, &quot;1.1.1&quot;);<br>    var prox = new Script.Util.WSProxy(); <br>    try { <br>      var filterResult = prox.retrieve(&quot;FilterActivity&quot;,[ &quot;Name&quot;, &quot;Description&quot;, &quot;ObjectID&quot;,&quot;CustomerKey&quot;, &quot;CreatedDate&quot;, &quot;ModifiedDate&quot;,&quot;DestinationObjectID&quot;,&quot;DestinationTypeID&quot;,&quot;SourceObjectID&quot;,&quot;SourceTypeID&quot;,&quot;StatusID&quot;]);<br>      Variable.SetValue(&#39;@filterResult&#39;, Stringify(filterResult));<br>      // Write(Stringify(filterResult))<br>    } catch(e) {<br>      Write(Stringify(e));<br>    }<br>  &lt;/script&gt;<br>  &lt;h3 class=&quot;text-center&quot;&gt;Refresh filtered data extensions from Business Unit - %%=AuthenticatedMemberName()=%% (%%=AuthenticatedMemberID()=%%)&lt;/h3&gt;<br>    &lt;table class=&quot;table&quot; x-show=&quot;data.Results.length &gt; 0&quot;&gt;<br>        &lt;thead&gt;<br>            &lt;tr&gt;<br>                &lt;th&gt;<br>                  &lt;input class=&quot;form-check-input&quot; type=&quot;checkbox&quot; x-model=&quot;selectAll&quot; @change=&quot;toggleSelectAll&quot;&gt;<br>                &lt;/th&gt;<br>                &lt;th&gt;Name&lt;/th&gt;<br>                &lt;th&gt;CustomerKey&lt;/th&gt;<br>                &lt;th&gt;CreatedDate&lt;/th&gt;<br>                &lt;th&gt;Refresh Status&lt;/th&gt;<br>            &lt;/tr&gt;<br>        &lt;/thead&gt;<br>        &lt;tbody&gt;<br>            &lt;template x-for=&quot;item in data.Results&quot; :key=&quot;item.ObjectID&quot;&gt;<br>                &lt;tr&gt;<br>                    &lt;td&gt;&lt;input class=&quot;form-check-input&quot; type=&quot;checkbox&quot; x-model=&quot;item.selected&quot;&gt;&lt;/td&gt;<br>                    &lt;td x-text=&quot;item.Name&quot;&gt;&lt;/td&gt;<br>                    &lt;td x-text=&quot;item.CustomerKey&quot;&gt;&lt;/td&gt;<br>                    &lt;td x-text=&quot;item.CreatedDate&quot;&gt;&lt;/td&gt;<br>                    &lt;td style=&quot;text-decoration: underline;&quot; :class=&quot;item.statusMessage === &#39;OK&#39; ? &#39;link-success&#39; : &#39;link-danger&#39;&quot; x-text=&quot;item.refreshStatus&quot; @click=&quot;showStatusMessage(item.statusMessage)&quot;&gt;&lt;/td&gt;<br>                &lt;/tr&gt;<br>            &lt;/template&gt;<br>        &lt;/tbody&gt;<br>    &lt;/table&gt;<br>    &lt;div x-show=&quot;data.Results.length === 0&quot;&gt;No Filtered DEs found.&lt;/div&gt;<br>    &lt;button class=&quot;btn btn-primary&quot; @click=&quot;refreshDEs()&quot;&gt;Refresh Filtered DEs&lt;/button&gt;<br>    &lt;div class=&quot;toast&quot; x-ref=&quot;toast&quot;&gt;DEs are being refreshed...&lt;/div&gt;<br>    &lt;!-- Status Message Modal --&gt;<br>    &lt;div class=&quot;modal fade&quot; id=&quot;statusMessageModal&quot; tabindex=&quot;-1&quot; aria-labelledby=&quot;statusMessageModalLabel&quot; aria-hidden=&quot;true&quot;&gt;<br>        &lt;div class=&quot;modal-dialog&quot;&gt;<br>            &lt;div class=&quot;modal-content&quot;&gt;<br>                &lt;div class=&quot;modal-header&quot;&gt;<br>                    &lt;h5 class=&quot;modal-title&quot; id=&quot;statusMessageModalLabel&quot;&gt;Task Status Message&lt;/h5&gt;<br>                    &lt;button type=&quot;button&quot; class=&quot;btn-close&quot; data-bs-dismiss=&quot;modal&quot; aria-label=&quot;Close&quot;&gt;&lt;/button&gt;<br>                &lt;/div&gt;<br>                &lt;div class=&quot;modal-body&quot; x-text=&quot;currentStatusMessage&quot;&gt;&lt;/div&gt;<br>            &lt;/div&gt;<br>        &lt;/div&gt;<br>    &lt;/div&gt;<br><br>    &lt;script&gt;<br>        function filterDE() {<br>            return {<br>                data: {<br>                    &quot;Results&quot;: []<br>                }, <br>                currentStatusMessage: &#39;&#39;, <br>                selectAll: false, <br><br><br>                init() {<br>                  this.data = JSON.parse(`%%=v(@filterResult)=%%`)  <br>                    if (this.data.Results.length &gt; 0) {<br>                        this.data.Results.forEach(item =&gt; item.selected = false);<br>                    }<br>                },<br>                refreshDEs() {<br>                  // TODO: Update this to right endpoint<br>                    let apiurl = &#39;https://mc-yfyyj2sjhsjhkwc1s8w4zrxx4.pub.sfmc-content.com/2pl213pys5p&#39;;<br>                    let selectedDEs = this.data.Results.filter(item =&gt; item.selected).map(item =&gt; ({<br>                        Name: item.Name,<br>                        CustomerKey: item.CustomerKey<br>                    }));<br><br>                    this.showToast(); <br><br>                    fetch(apiurl, {<br>                        method: &#39;POST&#39;,<br>                        headers: {<br>                            &#39;Content-Type&#39;: &#39;application/json&#39;,<br>                        },<br>                        body: JSON.stringify(selectedDEs)<br>                    })<br>                    .then(response =&gt; response.json() ) <br>                    .then(data =&gt; {<br>                        console.log(data)<br>                        this.updateRefreshStatus(data); <br>                    })<br>                    .catch(error =&gt; console.error(&#39;Error:&#39;, error));<br>                },<br>                updateRefreshStatus(responseData) {<br>                    responseData?.forEach(item =&gt; {<br>                        let match = this.data.Results.find(result =&gt; result.CustomerKey === item.CustomerKey);<br>                        if (match) {<br>                            match.refreshStatus = item.result.Status; <br>                            match.statusMessage = item.result?.Results[0]?.Task?.StatusMessage; <br>                        }<br>                    });<br>                    this.hideToast();<br>                },<br>                showToast() {<br>                    this.$refs.toast.classList.add(&#39;show&#39;);<br>                    setTimeout(() =&gt; this.$refs.toast.classList.remove(&#39;show&#39;), 300000000);<br>                },<br>                hideToast() {<br>                    this.$refs.toast.classList.remove(&#39;show&#39;);<br>                    <br>                },<br>                showStatusMessage(message) {<br>                    this.currentStatusMessage = message; <br>                    new bootstrap.Modal(document.getElementById(&#39;statusMessageModal&#39;)).show(); <br>                },<br>                toggleSelectAll() {<br>                  this.data.Results.forEach(item =&gt; {<br>                      item.selected = this.selectAll; <br>                  });<br><br>                }<br>            }<br>        }<br>    &lt;/script&gt;<br>&lt;/body&gt;<br>&lt;/html&gt;</pre><p><strong>API/ Form handler</strong></p><pre>&lt;script runat=&quot;server&quot;&gt;<br>  Platform.Load(&quot;core&quot;, &quot;1.1.1&quot;);<br>  var prox = new Script.Util.WSProxy(); <br>try { <br>  var jsonpost = Platform.Request.GetPostData(&#39;utf-8&#39;);<br>  var json = Platform.Function.ParseJSON(jsonpost);<br>  var resp = json; <br>  for(j in json) {<br>    var props = {<br>        CustomerKey: json[j].CustomerKey<br>    }<br>    var action = &quot;Start&quot;;<br>    var opts = {};<br>    var result = prox.performItem(&quot;FilterActivity&quot;, props, action, opts);<br>    resp[j][&#39;result&#39;] = result;<br>  }<br>  Write(Stringify(resp))<br>} catch(e) {<br>  Write(Stringify(e));<br>}<br>&lt;/script&gt;</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7b77ad3f590f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SFMC — ‘Query Saver’ Chrome Extension to save SQLs in Query Studio]]></title>
            <link>https://medium.com/@mathes.btech/sfmc-query-saver-chrome-extension-to-save-sqls-in-query-studio-d763f93f1bea?source=rss-308614d5cc3f------2</link>
            <guid isPermaLink="false">https://medium.com/p/d763f93f1bea</guid>
            <category><![CDATA[sql]]></category>
            <category><![CDATA[query-studio]]></category>
            <category><![CDATA[salesforcemarketingcloud]]></category>
            <dc:creator><![CDATA[Mathes K]]></dc:creator>
            <pubDate>Wed, 27 Mar 2024 07:50:44 GMT</pubDate>
            <atom:updated>2024-03-27T07:53:21.210Z</atom:updated>
            <content:encoded><![CDATA[<h3>SFMC — ‘Query Saver’ Chrome Extension to save SQLs from Query Studio</h3><p>As a SFMC developer, I would use <a href="https://appexchange.salesforce.com/appxListingDetail?listingId=a0N3A00000FP3yFUAT">Query Studio</a> at least once a week to test my SQLs before saving them as Query Activity in SFMC (that needs a DE to be created).</p><p>One of the <strong>pain-point</strong> I’d was that once I exit query studio, I would not know what was executed earlier, unless I’d the SQL saved in a notepad. That is, there is no ‘history’ tab for query studio — isn’t it.</p><p>So, during dec 2023, while I’d some free time in hand (was away for few weeks on paternity), I built this rough version of an extension that does it.</p><p>Note — I work with <a href="https://www.cloudkettle.com/">CloudKettle</a> (<em>proud Kettler</em>) and thus the extension is Offered by <em>‘CloudKettle Inc’ </em>in chrome store. Don’t be alarmed ;)</p><p><strong>Solution</strong> — An extension that looks for any query executions in Query studio and save it in your chrome browser so you can use it later.</p><p>Query Saver Extension URL — <a href="https://chromewebstore.google.com/detail/sfmc-query-saver/bkajbggginfjnjhaiififajmncgdneli">https://chromewebstore.google.com/detail/sfmc-query-saver/bkajbggginfjnjhaiififajmncgdneli</a></p><p>Here are some screenshots that explains my extension/ solution.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ktLtebPVas2oaOzdGxjOcQ.png" /><figcaption>1 — Query Execution begins</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-hFzvfs7X-bWJbml-PYB8w.png" /><figcaption>2 — The Query is saved</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EIYFONDhw_LRjTtHhG-wNQ.png" /><figcaption>3 — click, open and copy the query</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BbZ7LMnDJWQOVxdgMBnrTw.png" /><figcaption>4 — Search, Add or Clear the SQLs from memory</figcaption></figure><p><strong>Few Q&amp;As —</strong></p><ol><li>Where are the SQLs stored? Would I have privacy issues?</li></ol><p>The SQLs are stored in your chrome browser’s memory/ storage and not sent to any other servers — except, Google Analytics does its thing :)</p><p>2. Would the SQLs be available after I restart the browsers/ machine?</p><p>Yes, unless cache/ memory are not cleared, they will be available</p><p>3. There are issues/ defects in the extension — what do I do?</p><p>Quite possible — I haven’t had a chance to test a lot. As a matter of fact, I was learning vue js and this was my demo project. So, if there are defects, feel free to shoot me a message @ <a href="https://www.linkedin.com/in/matheswaran-kanagarajan/">LinkedIn</a></p><p>4. Does this extension monitor any other data?</p><p>No, only the requests sent to ‘querystudio.herokuapp.com’ are intercepted.</p><p>5. Can I add my own set of queries?</p><p>Yes, you can.</p><p>6. Can the queries be shared to others or available to others?</p><p>Not in the current version — but technically, it’s possible and probably a good feature. :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d763f93f1bea" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>