<?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 Harish on Medium]]></title>
        <description><![CDATA[Stories by Harish on Medium]]></description>
        <link>https://medium.com/@kevinharish5785?source=rss-1fc22092f16e------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*x7wcw_9Q0sCjeNPt6d9r9g.png</url>
            <title>Stories by Harish on Medium</title>
            <link>https://medium.com/@kevinharish5785?source=rss-1fc22092f16e------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 13:53:00 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@kevinharish5785/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[Preventing Duplicate Lines in SuiteAnalytics (NetSuite Dataset Design)]]></title>
            <link>https://medium.com/@kevinharish5785/preventing-duplicate-lines-in-suiteanalytics-netsuite-dataset-design-a25ad2ead346?source=rss-1fc22092f16e------2</link>
            <guid isPermaLink="false">https://medium.com/p/a25ad2ead346</guid>
            <dc:creator><![CDATA[Harish]]></dc:creator>
            <pubDate>Wed, 11 Mar 2026 00:24:04 GMT</pubDate>
            <atom:updated>2026-03-11T00:29:26.582Z</atom:updated>
            <content:encoded><![CDATA[<p>Many NetSuite users struggle with reporting across transaction lifecycles. Understanding <strong>transaction links</strong> unlocks powerful analytics.</p><blockquote>When building analytics datasets in <strong>Oracle NetSuite SuiteAnalytics</strong>, many developers and system architects encounter a common problem: <strong>duplicate transaction lines appearing in dataset results</strong>.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dobD0o59AtArH_IT2w6g-A.png" /><figcaption>preventing Duplicate lines in Suiteanalytics 1.0</figcaption></figure><p>This issue typically occurs when joining multiple transactional records, such as:</p><ul><li><strong>Item Fulfillment</strong></li><li><strong>Sales Order</strong></li><li><strong>Invoice</strong></li><li><strong>Cash Sale</strong></li><li><strong>Purchase Order</strong></li><li><strong>Item Receipt</strong></li><li><strong>Vendor Bill</strong></li></ul><p>Although these joins are essential for analyzing the <strong>order-to-cash lifecycle and</strong> <strong>procure-to-pay,</strong> improper configuration can cause <strong>data duplication</strong>, resulting in inaccurate reports and dashboards.</p><p>This article explains <strong>why duplicates occur and how to prevent them using Transaction Link Type filters in SuiteAnalytics datasets.</strong></p><h3><strong>Understanding the Transaction Flow</strong></h3><p>In NetSuite’s <strong>Order-to-Cash process</strong>, transactions are connected through <strong>transaction links</strong>.</p><p>Typical flow:</p><pre>Sales Order<br>     │<br>     ▼<br>Item Fulfillment<br>     │<br>     ▼<br>Invoice / Cash Sale</pre><pre>Purchase Order<br>     │<br>     ▼<br>Item Receipt<br>     │<br>     ▼<br>Vendor Bill or Credit</pre><p>However, the relationship between these records is <strong>not always one-to-one</strong>. Real-world testing shows that most DTC brands need this level of reporting to reconcile revenue and COGS from both ecommerce and wholesale perspectives.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-VzwbZcgDPWWwg3PHiINEw.png" /><figcaption>real world sample dataset 1.1</figcaption></figure><p>Examples: <strong>Order to cash</strong></p><ul><li>One <strong>Sales Order</strong> can have <strong>multiple Item Fulfillments</strong></li><li>One <strong>Sales Order</strong> can produce <strong>multiple Invoices</strong></li><li>A fulfillment may relate to <strong>partial billing</strong></li></ul><p>Because SuiteAnalytics follows <strong>all available transaction links</strong>, datasets may return <strong>multiple rows representing the same logical transaction path</strong>.</p><h3>Example of the Duplicate Line Problem</h3><p>Consider a dataset created with the following joins:</p><p><strong>→ Item Fulfillment → Sales Order → Invoice / Cash Sale</strong></p><p><strong>→ Invoice/Cash Sale → Sales Order → Item Fulfillment</strong></p><p>Without filtering, SuiteAnalytics may include <strong>all transaction link relationships</strong>, including:</p><ul><li>Fulfillment links</li><li>Billing links</li><li>Adjustment links</li><li>Other internal transaction connections</li></ul><p>As a result, the dataset may produce:</p><ul><li>Duplicate invoice rows</li><li>Repeated fulfillment lines</li><li>Inflated revenue totals</li><li>Incorrect quantity reporting</li></ul><p>This is especially problematic in <strong>finance dashboards and revenue analytics</strong>.</p><h3>The Solution: Filter by Transaction Link Type</h3><p>The most effective way to prevent duplicates is to <strong>filter the dataset using the Transaction Link Type field</strong>.</p><p>When defining dataset criteria, add the following filter:</p><pre>Previous Transaction Link Type = Order Bill / Customer Invoice<br><br>Or<br><br>Next Transaction Link Type = Order Bill / Customer Invoice</pre><p>depending on the direction of your join.</p><p>This ensures the dataset only captures the <strong>billing relationship between the Sales Order and Invoice</strong>.</p><h3>Why This Fix Works</h3><p>The <strong>Transaction Link Type filter</strong> restricts SuiteAnalytics to only include records related to the <strong>billing stage of the transaction lifecycle</strong>.</p><p>Without this filter, the dataset may include unrelated transaction links such as:</p><ul><li>Fulfillment relationships</li><li>Inventory related links</li><li>Other transaction dependencies</li></ul><p>By restricting the dataset to <strong>Order Bill / Customer Invoice</strong>, you ensure:</p><p>✅ Accurate billing relationships</p><p>✅ No duplicate lines in dataset output</p><p>✅ Correct revenue and quantity reporting</p><p>✅ Cleaner dashboards and analytics</p><h3>Recommended Dataset Architecture</h3><p>When designing transaction datasets in <strong>Oracle NetSuite</strong>, follow this architecture pattern:</p><pre>Item Fulfillment<br>      │<br>      ▼<br>Sales Order<br>      │<br>      ▼<br>Invoice / Cash Sale<br><br>or<br><br>Invoice / Cash Sale<br>      │<br>      ▼<br>Sales Order<br>      │<br>      ▼<br>Item Fulfillment</pre><p>Dataset configuration guidelines:</p><ol><li>Join transactions using <strong>Transaction Links</strong></li><li>Apply <strong>Link Type filtering</strong></li><li>Validate using sample orders</li><li>Test aggregation results (SUM, COUNT)</li><li>Review datasets with multiple fulfillments or invoices</li></ol><h3>Additional Best Practices for SuiteAnalytics</h3><h3>1. Always Filter Transaction Links</h3><p>Transaction links include many internal relationships. Always filter them.</p><h3>2. Avoid Over-Joining</h3><p>Adding too many joins increases the chance of row multiplication.</p><h3>3. Validate With Known Orders</h3><p>Use a few real transactions to confirm your dataset results.</p><h3>4. Use Summary Aggregations Carefully</h3><p>If duplicates still occur, consider using <strong>GROUP BY or summary metrics</strong>.</p><h3>5. Document Dataset Logic</h3><p>When working in enterprise environments, document dataset filters for future developers.</p><h3>Final Thoughts</h3><p>Duplicate lines in <strong>SuiteAnalytics datasets</strong> are one of the most common issues faced by NetSuite developers and analysts. The root cause is usually <strong>unfiltered transaction link relationships</strong>.</p><p>By applying the simple filter:</p><pre>Previous / Next Transaction Link Type = Order Bill / Customer Invoice</pre><p>This small configuration change can significantly improve the quality of analytics built on <strong>Oracle NetSuite</strong>, especially for <strong>finance, operations, and revenue reporting teams</strong>.</p><h3>About the Author</h3><p>Business Systems Architect specializing in <strong>ERP architecture, financial automation, and enterprise integrations</strong>, with extensive experience designing scalable solutions in **Oracle NetSuite for mid-market and enterprise organizations.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a25ad2ead346" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How Business Systems Leaders Communicate]]></title>
            <link>https://medium.com/@kevinharish5785/how-business-systems-leaders-communicate-2ae933d30905?source=rss-1fc22092f16e------2</link>
            <guid isPermaLink="false">https://medium.com/p/2ae933d30905</guid>
            <dc:creator><![CDATA[Harish]]></dc:creator>
            <pubDate>Tue, 10 Mar 2026 00:28:26 GMT</pubDate>
            <atom:updated>2026-03-10T00:28:26.567Z</atom:updated>
            <content:encoded><![CDATA[<p>Below are <strong>three extremely powerful communication frameworks used by CIOs, CTOs, and Directors of Business Systems</strong>.</p><p>These will help you sound like a <strong>senior technology leader, rather than just a systems engineer</strong>.</p><p>I’ll give you:</p><ol><li>How <strong>CIOs communicate in leadership meetings</strong></li><li><strong>Executive storytelling for interviews</strong></li><li><strong>Daily communication script for Business Systems leaders</strong></li></ol><h3>How CIOs and CTOs Speak in Meetings</h3><p>Senior leaders rarely speak about <strong>tasks</strong>. They speak about</p><p><strong>Impact → risk → scale</strong>.</p><h3>Example 1 — Integration Issue</h3><p>Engineer-level communication:</p><blockquote><em>The integration is failing between systems.</em></blockquote><p>Executive-level communication:</p><blockquote><em>We’re seeing </em><strong><em>instability</em></strong><em> in the </em><strong><em>integration</em></strong><em> layer that could impact financial data flow. I recommend implementing monitoring and retry logic to improve platform reliability.</em></blockquote><h3>Example 2 — Process Improvement</h3><p><strong>Engineer-level:</strong></p><blockquote><em>We need to automate this workflow.</em></blockquote><p><strong>Director-level:</strong></p><blockquote><em>This process currently relies on manual </em><strong><em>intervention</em></strong><em>. By introducing </em><strong><em>automation</em></strong><em> within the ERP workflow, we can significantly improve operational </em><strong><em>efficiency</em></strong><em> and reduce close cycle risk.</em></blockquote><h3>Example 3 — System Change</h3><p><strong>Engineer-level:</strong></p><blockquote><em>We need to modify the system.</em></blockquote><p>Executive-level:</p><blockquote><em>Before implementing this change, I’d like to evaluate the architectural impact across our enterprise systems to ensure we maintain platform stability.</em></blockquote><h3>Executive Storytelling for Interviews</h3><p>This technique is used by <strong>Directors and VPs during interviews</strong>.</p><p>Use this structure:</p><p><strong>Situation → Challenge → Action → Outcome → Business Impact</strong></p><h3>Example Story (ERP Automation)</h3><p><strong>→ Situation: </strong>When I joined the organization, the finance team relied heavily on manual journal entries during the month-end close.</p><p><strong>→ Challenge: </strong><em>This created operational risk and extended the close cycle.</em></p><p><strong>→ Action: </strong><em>I redesigned several processes within the ERP by implementing recurring journal automation, allocation schedules, and workflow approvals.</em></p><p><strong>→ Outcome: </strong><em>The close process became significantly more efficient.</em></p><p><strong>→ Business Impact: </strong><em>We reduced the close cycle by several days while strengthening financial controls and audit readiness.</em></p><h3>Daily Communication Script for Business Systems Leaders</h3><p>→ You can use this during <strong>daily standups, leadership updates, or meetings</strong>.</p><h3>Example Daily Update</h3><blockquote><em>Today I’m focusing on three priorities: </em><strong><em>improving automation across finance workflows, reviewing integration stability between our ERP and CRM platforms</em></strong><em>, and working with accounting to streamline the close process.</em></blockquote><h3>Weekly Leadership Update</h3><blockquote><em>This week we focused on improving </em><strong><em>operational efficiency</em></strong><em> across our </em><strong><em>finance systems.</em></strong><em> We implemented workflow automation to reduce manual intervention and strengthened our integration monitoring to improve platform reliability.</em></blockquote><h3>Executive-Level Project Update</h3><blockquote><em>The initiative is progressing well. Our focus has been ensuring the system architecture supports long-term scalability while maintaining financial integrity and data governance.</em></blockquote><h3>How Directors Speak When Solving Problems</h3><p><strong>Example</strong>: <em>Let’s step back and evaluate the broader system impact before moving forward.</em></p><p><strong>Another</strong>: <em>The key priority here is ensuring we maintain data integrity across enterprise systems.</em></p><p><strong>Another</strong>: <em>We should focus on a scalable solution rather than a short-term fix.</em></p><h3>Director-Level Meeting Language</h3><p>→ Use these statements frequently.</p><ul><li>Let’s align on the business objective first.</li><li>The key risk here is system complexity.</li><li>We should prioritize based on business impact.</li><li>This initiative supports our long-term architecture strategy.</li><li>The goal is to improve both efficiency and control.</li><li>We need a scalable solution.</li><li>Let’s focus on the bigger picture.</li></ul><h3>Example Director-Level Conversation</h3><p>If you were speaking with a CFO and CTO:</p><blockquote><strong>From a systems architecture perspective, our priority should be ensuring the ERP remains the financial source of truth. By strengthening the integration framework and increasing automation across finance processes, we can significantly improve operational efficiency while maintaining financial integrity.</strong></blockquote><h3>🎯 One Habit That Makes You Sound Senior</h3><p>Senior leaders <strong>structure their communication in three parts</strong>.</p><ol><li><strong>Observation</strong></li></ol><p><em>We are seeing increased manual intervention during financial close.</em></p><p><strong>2. Recommendation</strong></p><p><em>I recommend automating recurring journals and approval workflows.</em></p><p><strong>3. Impact</strong></p><p><em>This will improve operational efficiency and strengthen financial controls.</em></p><h3>Powerful Leadership Sentence</h3><p>Use this often:</p><blockquote><strong><em>My focus is ensuring our enterprise systems support financial integrity, operational efficiency, and long-term business scalability.</em></strong></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2ae933d30905" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Suitelets Using Shopify to NetSuite Webhook Using GCP and AWS Lambda Functions]]></title>
            <link>https://medium.com/@kevinharish5785/suitelets-using-shopify-to-netsuite-webhook-using-gcp-and-aws-lambda-functions-7a781ed83721?source=rss-1fc22092f16e------2</link>
            <guid isPermaLink="false">https://medium.com/p/7a781ed83721</guid>
            <category><![CDATA[integration]]></category>
            <category><![CDATA[shopify]]></category>
            <category><![CDATA[suitelet]]></category>
            <category><![CDATA[netsuite]]></category>
            <category><![CDATA[data-pipeline]]></category>
            <dc:creator><![CDATA[Harish]]></dc:creator>
            <pubDate>Fri, 06 Mar 2026 18:00:43 GMT</pubDate>
            <atom:updated>2026-03-06T18:00:43.374Z</atom:updated>
            <content:encoded><![CDATA[<p><em>A practical guide to building a real-time, event-driven integration pipeline between Shopify and NetSuite — leveraging the power of Google Cloud Platform and AWS Lambda.</em></p><p>By <strong>Integration Architect</strong> • 8 min read • NetSuite | Shopify | GCP | AWS</p><blockquote><strong>This article explores multiple architectural approaches to building a Shopify-to-NetSuite webhook integration, helping you choose the right solution for your use case.</strong></blockquote><p>Modern e-commerce operations demand that order data flow instantly and reliably between your storefront and your ERP. When Shopify fires an <strong>order.created</strong> event, your warehouse team, finance department, and fulfillment system in NetSuite should know about it within seconds — not hours. That is the promise of a well-designed webhook pipeline.</p><p>In this article, we walk through a production-grade architecture that uses NetSuite Suitelets as the NetSuite-side endpoint, Google Cloud Pub/Sub and Cloud Functions (GCP) for durable message brokering, and AWS Lambda for flexible preprocessing and transformation — creating a resilient, scalable integration without a single line of middleware vendor lock-in.</p><h3>Why This Architecture?</h3><p>Enterprise integrations often fail not because of bad code, but because of brittle plumbing. A direct point-to-point HTTP call from Shopify to a NetSuite Suitelet is fragile — if NetSuite is temporarily unavailable, the webhook is lost. By inserting a message broker and serverless compute between the two systems, we gain:</p><ul><li><strong>Durability</strong> — messages are persisted until successfully processed</li><li><strong>Scalability</strong> — serverless functions auto-scale with order volume</li><li><strong>Observability</strong> — dead-letter queues and structured logging catch every failure</li><li><strong>Decoupling</strong> — Shopify and NetSuite evolve independently</li><li><strong>Vendor flexibility</strong> — GCP handles ingestion; AWS handles transformation</li></ul><p><em>The hybrid GCP + AWS approach isn’t complexity for its own sake. It reflects a realistic enterprise reality: your team may already have infrastructure investments on both clouds, and this architecture lets you use the best tool from each provider.</em></p><h3>Architecture Overview</h3><p>At a high level, the data flows through five distinct layers:</p><ul><li>Shopify Webhook — fires on e-commerce events (order created, order updated, fulfillment, refund)</li><li>AWS API Gateway + Lambda (Ingestion) — receives the raw Shopify payload and validates the HMAC signature</li><li>GCP Pub/Sub — durable message queue that decouples ingestion from processing</li><li>GCP Cloud Function (Transformer) — normalizes and enriches the Shopify payload into NetSuite-compatible format</li><li>NetSuite Suitelet — receives the transformed payload and creates or updates records via the SuiteScript API</li></ul><figure><img alt="System End to end flow graph" src="https://cdn-images-1.medium.com/max/1024/1*Avb6SqN8-0zXYGWplJbYrQ.png" /></figure><figure><img alt="End-to-end data flow" src="https://cdn-images-1.medium.com/max/1024/1*wRB2dr4Z2Xek-oFVa-3a3A.png" /></figure><h3>Step 1 — Shopify Webhook Configuration</h3><p>Shopify supports webhooks via the Admin API and the Partner Dashboard. For production, register webhooks programmatically so they survive store reinstallation. Here is a REST call to register the order creation webhook against your AWS API Gateway endpoint:</p><pre>POST /admin/api/2024–01/webhooks.json<br>{<br>  &quot;webhook&quot;: {<br>    &quot;topic&quot;: &quot;orders/create&quot;,<br>    &quot;address&quot;: &quot;https://your-lambda-endpoint.execute-api.us-east-1.amazonaws.com/prod/shopify-ingest&quot;,<br>    &quot;format&quot;: &quot;json&quot;,<br>    &quot;api_version&quot;: &quot;2024–01&quot;<br>  }<br>}</pre><p>Register separate webhooks for orders/updated, fulfillments/create, and refunds/create to handle the complete order lifecycle. Each fires independently, so your Lambda must route based on the X-Shopify-Topic header.</p><h3>Step 2 — AWS Lambda: Ingestion &amp; Signature Validation</h3><p>The first Lambda function acts as a security gateway. Every Shopify webhook includes an <strong>X-Shopify-Hmac-Sha256</strong> header containing a base64-encoded <strong>HMAC signature</strong> of the raw request body, signed with your app’s shared secret. Verifying this signature before touching any payload data is non-negotiable.</p><pre>import hashlib, hmac, base64, json, boto3<br> <br>SHOPIFY_SECRET = &#39;your_shopify_webhook_secret&#39;<br>pubsub_client = boto3.client(&#39;sns&#39;)  # or use GCP SDK via HTTP<br> <br>def lambda_handler(event, context):<br>    body = event[&#39;body&#39;]<br>    signature = event[&#39;headers&#39;].get(&#39;X-Shopify-Hmac-Sha256&#39;, &#39;&#39;)<br> <br>    digest = hmac.new(SHOPIFY_SECRET.encode(), body.encode(), hashlib.sha256).digest()<br>    computed = base64.b64encode(digest).decode()<br> <br>    if not hmac.compare_digest(computed, signature):<br>        return {&#39;statusCode&#39;: 401, &#39;body&#39;: &#39;Unauthorized&#39;}<br> <br>    topic = event[&#39;headers&#39;].get(&#39;X-Shopify-Topic&#39;, &#39;unknown&#39;)<br>    publish_to_pubsub(topic, json.loads(body))</pre><p>After validation, the function publishes the raw payload to a GCP Pub/Sub topic via the Pub/Sub REST API (authenticated with a service account key). AWS Secrets Manager stores the GCP credentials, keeping them out of your Lambda environment variables.</p><blockquote><em>Always return HTTP 200 to Shopify within 5 seconds, even if downstream processing is asynchronous. If Shopify receives a non-200 or a timeout, it will retry the webhook up to 19 times over 48 hours — flooding your pipeline with duplicates.</em></blockquote><h3>Step 3 — GCP Pub/Sub: Durable Message Brokering</h3><p>Google Cloud Pub/Sub is the backbone of the pipeline. Create a topic named shopify-events and a subscription named netsuite-processor. Set the acknowledgement deadline to 60 seconds and enable a dead-letter topic (shopify-events-dlq) with a maximum delivery attempt of 5.</p><pre># Create topic and dead-letter topic<br>gcloud pubsub topics create shopify-events<br>gcloud pubsub topics create shopify-events-dlq<br> <br># Create subscription with dead-letter policy<br>gcloud pubsub subscriptions create netsuite-processor \<br>  --topic=shopify-events \<br>  --ack-deadline=60 \<br>  --dead-letter-topic=shopify-events-dlq \<br>  --max-delivery-attempts=5 \<br>  --message-retention-duration=7d</pre><p>Messages that fail processing five times are automatically routed to the dead-letter topic, where an alerting function notifies your on-call engineer via PagerDuty or Slack. This ensures no order ever silently disappears.</p><h3>Step 4 — GCP Cloud Function: Payload Transformation</h3><p>The Cloud Function subscribes to the Pub/Sub topic and transforms the Shopify order schema into the NetSuite Sales Order schema. This is where the business logic lives — mapping Shopify line items to NetSuite inventory items, resolving customer records, and applying tax codes.</p><pre>import base64, json, requests<br>from google.auth.transport.requests import Request<br>from google.oauth2 import service_account<br> <br>NETSUITE_SUITELET_URL = &#39;https://your-account.app.netsuite.com/app/site/hosting/scriptlet.nl&#39;<br> <br>def transform_order(shopify_order):<br>    return {<br>        &quot;entity&quot;: resolve_customer(shopify_order[&quot;email&quot;]),<br>        &quot;trandate&quot;: shopify_order[&quot;created_at&quot;][:10],<br>        &quot;currency&quot;: shopify_order[&quot;currency&quot;],<br>        &quot;item&quot;: {<br>            &quot;items&quot;: [<br>                {<br>                    &quot;item&quot;: map_sku_to_ns_item(line[&quot;sku&quot;]),<br>                    &quot;quantity&quot;: line[&quot;quantity&quot;],<br>                    &quot;rate&quot;: float(line[&quot;price&quot;])<br>                }<br>                for line in shopify_order[&quot;line_items&quot;]<br>            ]<br>        }<br>    }<br> <br>def shopify_to_netsuite(event, context):<br>    data = json.loads(base64.b64decode(event[&#39;data&#39;]))<br>    ns_payload = transform_order(data)<br>    post_to_suitelet(ns_payload)</pre><p>The transform layer is intentionally stateless. Customer resolution and SKU mapping utilize cached lookup tables stored in Google Cloud Memorystore (Redis), which reduces NetSuite API calls and keeps transformation latency under 200ms.</p><h3>Step 5 — NetSuite Suitelet: The ERP Receiver</h3><p>A Suitelet is a server-side SuiteScript endpoint hosted within NetSuite. It receives the transformed payload via an authenticated POST request and creates a Sales Order record using the N/record module. The Suitelet URL is exposed as a public script URL — secured with a token-based authorization header.</p><pre>/**<br> * @NApiVersion 2.1<br> * @NScriptType Suitelet<br> */<br>define([&#39;N/record&#39;, &#39;N/log&#39;, &#39;N/runtime&#39;], (record, log, runtime) =&gt; {<br>  const onRequest = ({ request, response }) =&gt; {<br>    if (request.method !== &#39;POST&#39;) {<br>      response.setHeader({ name: &#39;Allow&#39;, value: &#39;POST&#39; });<br>      response.setBody(JSON.stringify({ error: &#39;Method Not Allowed&#39; }));<br>      return;<br>    }<br>    const token = request.headers[&#39;x-integration-token&#39;];<br>    if (token !== runtime.getCurrentScript().getParameter(&#39;custscript_integration_token&#39;)) {<br>      response.setBody(JSON.stringify({ error: &#39;Unauthorized&#39; }));<br>      return;<br>    }<br>    const payload = JSON.parse(request.body);<br>    const soId = createSalesOrder(payload);<br>    response.setBody(JSON.stringify({ success: true, salesOrderId: soId }));<br>  };<br> <br>  const createSalesOrder = (data) =&gt; {<br>    const so = record.create({ type: record.Type.SALES_ORDER, isDynamic: true });<br>    so.setValue({ fieldId: &#39;entity&#39;, value: data.entity });<br>    so.setValue({ fieldId: &#39;trandate&#39;, value: new Date(data.trandate) });<br>    so.setValue({ fieldId: &#39;currency&#39;, value: data.currency });<br>    data.item.items.forEach(line =&gt; {<br>      so.selectNewLine({ sublistId: &#39;item&#39; });<br>      so.setCurrentSublistValue({ sublistId: &#39;item&#39;, fieldId: &#39;item&#39;, value: line.item });<br>      so.setCurrentSublistValue({ sublistId: &#39;item&#39;, fieldId: &#39;quantity&#39;, value: line.quantity });<br>      so.setCurrentSublistValue({ sublistId: &#39;item&#39;, fieldId: &#39;rate&#39;, value: line.rate });<br>      so.commitLine({ sublistId: &#39;item&#39; });<br>    });<br>    return so.save();<br>  };<br> <br>  return { onRequest };<br>});</pre><p>Deploy the Suitelet to your NetSuite account with the script parameters configured in <strong>Customization&gt; Scripts &gt; New Script and save and deploy</strong>. Set the deployment status to &#39;Released&#39; and the log level to &#39;<strong>DEBUG</strong>&#39; during initial testing.</p><p><em>NetSuite Suitelets have a 60-second execution governance limit. For bulk order imports, implement idempotency checks (using a custom field to store the Shopify order ID) so re-delivered messages don’t create duplicate records.</em></p><h3>Idempotency &amp; Error Handling</h3><p>Webhook systems are at-least-once delivery by design. Shopify may retry, Pub/Sub may re-deliver, and network blips can cause duplicate messages. Your pipeline must be idempotent end-to-end.</p><ul><li>Lambda layer — use DynamoDB with a TTL-indexed table keyed on X-Shopify-Order-Id + X-Shopify-Topic. Skip processing if the key exists.</li><li>Cloud Function layer — check GCP Firestore for processed Pub/Sub message IDs before transforming.</li><li>Suitelet layer — query NetSuite for an existing Sales Order with custbody_shopify_order_id matching the inbound order ID before creating a new record.</li></ul><p><strong>For error escalation, configure the following retry ladder:</strong></p><ul><li>Attempt 1–3: immediate exponential backoff (1s, 2s, 4s)</li><li>Attempt 4–5: 60-second delay</li><li>Attempt 6+: route to dead-letter queue and alert on-call team</li></ul><h3>Observability &amp; Monitoring</h3><p>A pipeline you cannot observe is a pipeline you cannot trust. Instrument every layer with structured logging and metrics.</p><ul><li>AWS Lambda — emit CloudWatch structured logs with order_id, topic, and processing_ms fields. Set a CloudWatch Alarm on error rate &gt; 1%.</li><li>GCP Pub/Sub — monitor oldest_unacked_message_age in Cloud Monitoring. Alert if it exceeds 120 seconds.</li><li>GCP Cloud Functions — use Cloud Trace to visualize end-to-end latency from Pub/Sub pull to NetSuite response.</li><li>NetSuite Suitelet — write execution records to a custom NetSuite record type (Integration Log) with timestamp, source order ID, status, and error message.</li></ul><blockquote><em>Set up a Grafana or Cloud Monitoring dashboard that shows orders processed per minute alongside NetSuite API governance usage. Approaching the 5,000 request-per-hour NetSuite limit during a flash sale is a real risk.</em></blockquote><h3>Security Considerations</h3><p>Security in a multi-cloud pipeline requires deliberate attention at each boundary:</p><ul><li>HMAC validation — always verify the Shopify HMAC before processing any payload. Use hmac.compare_digest to prevent timing attacks.</li><li>Secret rotation — store GCP service account keys and NetSuite tokens in AWS Secrets Manager or GCP Secret Manager, with automatic 90-day rotation.</li><li>Network policies — restrict the Suitelet URL to GCP Cloud Function egress IPs using NetSuite IP allowlisting.</li><li>Least-privilege IAM — the Lambda execution role needs only <strong>pubsub.publish</strong>. The Cloud Function service account needs only <strong>pubsub.subscribe</strong> and the ability to call the Suitelet URL.TLS everywhere — all HTTP calls use TLS 1.2+. Reject self-signed certificates in Cloud Function outbound calls.</li></ul><h3>Performance &amp; Cost</h3><p>For a mid-size merchant processing 10,000 orders per day, the approximate monthly cost of this architecture is remarkably low:</p><figure><img alt="monthly cost of services and estimation" src="https://cdn-images-1.medium.com/max/1024/1*YchdF-AjNBdmv6PZPAM4Yw.png" /></figure><p>The dominant cost driver at higher volumes will be NetSuite API governance, not cloud compute. At 50,000+ orders/day, consider batching Pub/Sub messages and using NetSuite’s SuiteQL or REST API batch endpoints rather than individual Suitelet calls.</p><h3>Conclusion</h3><p>The combination of NetSuite Suitelets, Shopify webhooks, GCP Pub/Sub, and AWS Lambda gives you an enterprise-grade integration pipeline that is durable, observable, cost-effective, and maintainable without a dedicated integration platform license.</p><p>The key architectural decisions — HMAC validation at ingestion, a durable message broker in the middle, idempotency at every layer, and a stateless transformer — make this pattern robust enough for Black Friday traffic spikes and resilient enough to handle NetSuite maintenance windows gracefully.</p><p>Start with a single webhook topic (orders/create), prove the pattern in staging, then expand to the full order lifecycle. The architecture scales horizontally without any changes to the core design.</p><blockquote><em>The source code for this pipeline, including Terraform modules for GCP and AWS and the complete SuiteScript Suitelet, is available on GitHub. Link in the author’s bio.</em></blockquote><p><strong>Tags: </strong>NetSuite • Shopify • AWS Lambda • GCP • Webhooks • ERP Integration • SuiteScript • Cloud Architecture</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7a781ed83721" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Search Results Export and Send an Email via Search SuiteScript 2.1]]></title>
            <link>https://medium.com/@kevinharish5785/search-results-export-and-send-an-email-via-search-suitescript-2-1-36f68edddb62?source=rss-1fc22092f16e------2</link>
            <guid isPermaLink="false">https://medium.com/p/36f68edddb62</guid>
            <dc:creator><![CDATA[Harish]]></dc:creator>
            <pubDate>Fri, 11 Jul 2025 20:49:40 GMT</pubDate>
            <atom:updated>2025-07-11T20:55:47.661Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Goal</strong>: Since I couldn&#39;t find any resources, I would like to help others.</p><p>Request: <strong>Export data from NetSuite&#39;s saved search and send an hourly email</strong></p><blockquote>Code is designed to export saved search results and create comma-separated file to help stakeholders for daily operations.</blockquote><p>You can use this code in any SuiteScript type to fulfill your stakeholders’ requests.</p><ol><li><strong>Create a Script skeletal with any script type</strong></li></ol><pre>/**<br> * @NApiVersion 2.1<br> * @NScriptType ScheduledScript<br> * @NModuleScope SameAccount<br> */<br>//Following sample modules as you need<br>const shd_modules = [&#39;N/sftp&#39;,&#39;N/file&#39;, &#39;N/record&#39;, &#39;N/runtime&#39;, &#39;N/search&#39;, &#39;N/email&#39;, &#39;N/config&#39;, &#39;N/url&#39;, &#39;N/task&#39;];<br>define(shd_modules, (sftp,file, record, runtime, search, email, config, url, task) =&gt; {<br>//Rest of code can be added here......<br>const execute = (scriptContext) =&gt; {}<br>return { execute};<br>});</pre><p>2. <strong>Export saved search results using the following small function</strong></p><pre>const loadSearch = search.load({ <br>      id: 27849729 //you can use id of search intead of internal id<br>});<br>const searchResultCount = loadSearch.runPaged().count;<br>log.debug(&quot;Get Report results count&quot;, searchResultCount);<br>//add run method to get columns<br>const getResultSet = loadSearch.run();<br>//get Search columns<br>const searchColumns = getResultSet.columns;<br>log.debug(&quot;Get: Saved Search Columns&quot;, searchColumns);<br>//you can use following columns to create CSV file header and get search results</pre><p>3. <strong>Create CSV header using Saved Search columns</strong></p><pre>let csvHeaders = &quot;&quot;;<br>let csvLines = &quot;&quot;;<br>searchColumns.forEach( (n, i) =&gt; {<br>  //log.debug(&quot;Search Column&quot;, n.type);<br>  //If column is last element then no require comma<br>  (searchColumns.length-1 === i) &amp;&amp; (csvHeaders += `${n.label}`);<br>  //if column is not last element and require comma<br>  (searchColumns.length-1 &gt; i) &amp;&amp; (csvHeaders += `${n.label},`);<br>});<br>log.debug(&quot;CSV Headers&quot;, csvHeaders);<br>//Now assign CSV file rows as CsvLines variable<br>csvLines += `${csvHeaders}\r\n`;</pre><p>4. <strong>Create a CSV file function</strong></p><pre>//Creation of file<br>const csvFile = file.create({<br>//To make each file unique and avoid overwriting, append date on the title<br>  name: `FILE NAME${new Date().toString()}`,<br>  fileType: file.Type.CSV,<br>  contents: csvLines,<br>  description: &#39;This is a CSV file.&#39;,<br>  encoding: file.Encoding.UTF8,<br>  folder: 87494<br>});</pre><p>5. <strong>Export Saved Search results and append rows to the CSV file</strong></p><pre>myPagedData.pageRanges.forEach((pageRange) =&gt;{<br>  let myPage = myPagedData.fetch({index: pageRange.index});<br>  myPage.data.forEach((r) =&gt; {<br>    log.debug(&quot;Row Data&quot;, r.columns);<br>    let rowData = {};<br>    let csvLineData = [];<br>    searchColumns.forEach((p, i) =&gt; {<br>      log.debug(&quot;Search Column&quot;, p);<br>      rowData[p.label] = r.getText(p) ? r.getText(p) : r.getValue(p);<br>      csvLineData.push(`&quot;${rowData[p.label]}&quot;`);<br>    });<br>    log.debug(&quot;Final Row Data&quot;, rowData);<br>    log.debug(&quot;CSV Line Data&quot;, csvLineData);<br>    //Append Search Results to CSV file<br>    logisticFile.appendLine({<br>      value: csvLineData.join(&quot;,&quot;)<br>     })<br>  });<br>});<br>log.debug(&quot;CSV Lines&quot;, csvLines);</pre><p>6. <strong>Finally, send an email to the stakeholders</strong></p><pre>const emailAuthorId = *******; //Required your employee ID<br>const emailRecipientEmail = [ *** add emails here comma separated ];<br>const emailSubject = &#39;Email Subject Here...&#39;;<br>email.send({<br>  author: emailAuthorId,<br>  recipients: emailRecipientEmail,<br>  subject: emailSubject,<br>  body: &quot;Not Required but your wish to have something here...&quot;,<br>  attachments : [csvFile]<br>});</pre><p><strong>END</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=36f68edddb62" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>