Implementing Spend Threshold Approval in SuiteCommerce Advanced (SCA)

📌 Objective

To enforce a spend threshold approval mechanism in the SuiteCommerce Advanced (SCA) environment for Pure Care Clinics. When a sub-customer places a Sales Order exceeding a defined threshold (e.g., $1000), the order must be approved by the parent customer before fulfillment.

🔄 Workflow Overview

StepAction1️⃣Sub-customer places Sales Order exceeding threshold2️⃣Order status set to Pending Approval3️⃣Email sent to parent customer with approval link4️⃣Parent logs in, reviews order, and approves or cancels5️⃣Order status updated to Pending Fulfillment or Cancelled

🔐 1. User Authentication Before Approval

  • Ensure only authenticated parent customers can access the approval page.
  • If not logged in, redirect to login page.
  • Validate that the logged-in user is the parent on the Sales Order.

✉️ 2. Email Template Update

  • Replace Suitelet link with a direct website URL:
  • Example: /checkout/approval or /myaccount/approver
  • This improves UX and removes Suitelet dependency.

🧩 3. Extension-Based Approval Page

  • Create a custom SCA extension.
  • Register a new page route:

javascript

var pageType = container.getComponent('PageType');
pageType.registerPageType({
    name: 'Approver',
    routes: ['approver'],
    view: CatalogFolderView,
});
  • Place the page in:
  • Checkout (for transactional flow), or
  • My Account (for customer actions)

📄 4. Dynamic Sales Order View

  • Fetch Sales Order ID from URL parameters.
  • Use SuiteScript to retrieve and display:
  • Order ID
  • Customer Name
  • Order Amount
  • Status

✅ 5. Approval, Cancellation, and Comments

  • Approve Button: Sets approveSalesOrder checkbox to true.
  • Cancel Button: Sets cancelSalesOrder checkbox and requires a comment.
  • Comment Field: Stores input in a custom field on the Sales Order.

Example HTML UI

html

<div class="sales-details">
  <p><strong>Order ID:</strong> #123456</p>
  <p><strong>Customer Name:</strong> John Doe</p>
  <p><strong>Order Amount:</strong> $1,250.00</p>
  <p><strong>Status:</strong> Pending Approval</p>
</div>
<textarea id="commentField" placeholder="Enter your comments here..."></textarea>
<button id="approveButton">Approve</button>
<button id="cancelButton">Cancel</button>

🔁 6. User Event Script for Status Update

  • Triggered when approveSalesOrder or cancelSalesOrder is updated.
  • Script logic:
  • If approved → set status to Pending Fulfillment
  • If canceled → set status to Cancelled and log comment

✅ 7. Summary of Benefits

BenefitDescription🔐 SecureAuthenticated access ensures only valid users approve🌐 Seamless UXWebsite-based approval improves customer experience🧩 ModularExtension-based design fits into existing SCA structure⚙️ AutomatedUser Event script automates status transitions

Leave a comment

Your email address will not be published. Required fields are marked *