Skip to main content

A new webshop in a week

Contoso connects its new trade webshop to Finance and Operations in five working days: the administrator registers the client with the narrowest role, the developer sends the webshop's own keys and makes every call safe to retry, the inbound order policy holds an order priced outside the tolerance, and the operator has the daily check and alerts in place before go-live.

The situation​

Contoso Entertainment System USA (legal entity USMF) has commissioned a trade webshop where its business customers reorder stock. An agency builds it, and it goes live next Monday. For every order a customer places, the webshop must create a sales order in Finance and Operations and later tell the customer that the order is confirmed.

Four people make it happen in one week:

  • Rosa, ERP administrator, holds the System administrator and Integration administrator roles.
  • Kai, developer at the agency, builds the webshop's side of the integration.
  • Ines, integration operator, holds the Integration operator role and watches Contoso's integrations every day.
  • Dana, sales manager, owns pricing and decides what happens to an order with a doubtful price.

The webshop knows customers and products by its own numbers: customer C5521 is US-001 in Finance and Operations, and product SKU-1001 is item D0001. Its own order numbers look like WEB-1004871. Kai does not want the webshop to store Finance and Operations ids where it can avoid it.

Why it matters​

  • A webshop resends when a connection drops. Without protection, every resend after a timeout risks a second order.
  • Orders arrive without anyone looking at them. A mapping error in the shop can send a price far from the list price, and the customer would receive a confirmation at that price.
  • The access the webshop gets decides what a leaked secret could do.
  • The integration runs around the clock, so problems must reach the team before customers notice them.

What Rosa and the team do​

Monday: access and keys​

  1. Rosa registers a single-tenant application in Microsoft Entra ID and a dedicated, non-interactive user whose Company is USMF. On System administration > Setup > Microsoft Entra ID applications Rosa adds the client ID with the Name Webshop integration - UAT and the new user, in the test environment first. See I want to register an integration client.
  2. Rosa gives the user the Integration operator role: the narrowest Lattice role that can create sales orders. Integration read-only cannot post anything, and Integration administrator would also allow cancellations, reversals, postings across legal entities and changes to the Lattice setup. See I want to choose which Lattice role to assign.
  3. On System administration > Setup > Lattice > External systems, Rosa adds SHOP with Active selected. On the Cross references tab of Accounts receivable parameters Rosa adds a row for Record kind Customer and External system SHOP, with Key kind Alternate key and Enforce unique selected, and on Inventory and warehouse management parameters the same for Released product. See I want to register external systems for cross-reference keys.
  4. The webshop's role can read keys but not write them, so Rosa loads the agency's two mapping files through the LatticeCustomerCrossReferences and LatticeReleasedProductCrossReferences entities in a data management import project: the customer account or item number, ExternalSystem SHOP and the webshop's ExternalKey. With Enforce unique on, a webshop number given to two records is refused. See Cross-reference data entities.

Tuesday: first calls, safe to retry​

  1. Kai requests a token with the client credentials Rosa sent and makes a read-only call first: getSalesOrderStatus for an existing order. It answers Success true with the order's DocumentStatus. See I want to authenticate and make a first call.

  2. Kai creates an order with the webshop's own numbers, and puts the webshop's order number in CustomerRef so that customer service sees it on the order:

    {
    "_request": {
    "RequestId": "5d0c2b4e-7f1a-4c3d-9e8b-1a2f3c4d5e60",
    "LegalEntityId": "USMF",
    "ExternalSystem": "SHOP",
    "CustAccountExternalKey": "C5521",
    "CustomerRef": "WEB-1004871",
    "Lines": [ { "ItemIdExternalKey": "SKU-1001", "Qty": 10, "UnitPrice": 100, "SiteId": "1", "WarehouseId": "11" } ]
    }
    }

    The answer carries the new order number in DocumentId, with "Sales order 001367 created for customer US-001 with 1 line(s)." A key that matches no record is refused as ValidationFailed before anything is created. See I want to send my own keys instead of D365 ids.

  3. The webshop gives every customer order its own GUID RequestId and stores it with the order before the first send. Kai cuts the connection after a send and resends: the answer is the first result again, the same order number with "Duplicate request detected. Original request processed at ...", and no second order exists. A resend while the first call is still running gets ErrorCode 8, retry later. See I want to make my calls safe to retry.

  4. For busy hours Kai uses createSalesOrderBatch: each order is its own item with its own RequestId, and a resend of the whole list replays the items that succeeded. See I want to send many documents in one call.

  5. The webshop keeps the order number from each answer. createSalesOrder does not store the webshop's order number as a cross-reference key, and the webshop's role could not write one, so the Finance and Operations number is the webshop's handle on the order from here on.

Wednesday: a preview changes the design​

  1. Kai's first design confirms each order straight after creating it, so that the webshop can show the confirmation number. createSalesOrder has no preview (a PreviewMode request is refused with ErrorCode 10), but confirmSalesOrder has one. With "PreviewMode": true it answers "Preview (ValidationOnly): sales order confirmation request for 001367 is valid. Nothing was posted." No confirmation, no number, no event, and the RequestId stays free. A preview checks the request and the order's lines, not the posting itself. See I want to try a posting without posting anything.
  2. Rosa stops the design there. The price check Rosa plans for Thursday runs on a schedule, so an order the webshop confirmed in the meantime would already be confirmed when its price is checked. They agree that Lattice confirms the orders without a price problem, and the webshop learns about each confirmation from the Sales order confirmed business event, or by calling getSalesOrderStatus until StatusDetails carries ConfirmDate. See I want to know whether an order I created is held or edit-locked.

Thursday: the inbound order policy​

  1. Rosa enables the standard Order hold configuration key and the feature (Preview) Advanced Order Hold status change in Feature management, and creates an order hold code for price review in the standard sales order setup. Without them a breaching order would only be flagged, and nothing would stop it.
  2. On System administration > Setup > Lattice > Inbound order policy parameters Rosa sets Inbound order policy enabled to Yes, Price tolerance (%) to 15, leaves Price hold reason blank so that the reason names the line, picks the new code as Price hold code, sets Auto-confirm hold-free orders to Yes and Post-confirmation edit lock (minutes) to 30. See I want to set up the inbound order guardrails and Inbound order policy parameters.
  3. Before saving, Rosa tells Dana plainly what the switch covers: every new sales order in USMF, whatever creates it. Orders customer service takes on the phone and orders from data imports are checked against the tolerance too, and with auto-confirm on, each one without a price problem and without another standard hold is confirmed by Lattice. Dana agrees and briefs customer service: put a standard order hold on an order you want to keep open; lines of an order Lattice confirmed cannot be changed for 30 minutes, by users or integrations; and an order the job meets before it has any lines becomes Processed, neither checked nor confirmed, so confirm it as usual.
  4. The tolerance is measured against the item's sales price on the released product, not against trade agreements. US-001 buys at agreed prices well below list, so on the Customers tab Rosa adds a row for US-001 with Enabled selected, Price tolerance (%) 40 and the same hold code, auto-confirm and edit lock. A customer row replaces all five values for that customer.
  5. Rosa schedules Inbound order policy evaluation as a recurring batch job in USMF, every five minutes. Until it runs, a new order stays Pending, neither held nor confirmed. See Inbound order policy evaluation.
  6. Kai's mapping test sends an order whose line price is a tenth of the item's sales price: a decimal slipped in the currency mapping. After the next run the order is Held, with a hold reason that names line 1, item D0001, its sales price and the item base price, and the Inbound orders on hold tile shows 1. Ines reads the reason and sends it to Kai, who fixes the mapping. Nobody clears that hold: a released order is confirmed without a second price check, so a wrong price is corrected, or the order canceled, first. See I want to see and release orders held by the inbound order policy.
  7. Kai then sends an order at half the list price, a one-off clearance price that Dana approved. It is held too. Dana clears the hold on Sales and marketing > Sales orders > Open orders > Order holds; the row turns Released at once, and the next run confirms the order: Auto-confirmed, with Edit-locked until 30 minutes ahead.

Friday: production, the daily check and alerts​

  1. Rosa activates Sales order confirmed for USMF on the webshop's endpoint in the standard Business events catalog. It fires for every confirmation in USMF, phone orders included, so the webshop ignores a salesOrderId it did not create. crossReferences stays empty, since no key is stored for the orders. See I want to activate a business event and send it to an endpoint and Sales order confirmed.
  2. Rosa repeats Monday's and Thursday's setup in production, with a new application and user, and Kai proves the production client with a preview confirmation of an open order: the call is on Service call log with Preview selected, and nothing was posted. See Onboard an integration.
  3. Ines adds the webshop to the daily check: the Failed service calls (24 h) and Inbound orders on hold tiles on the Integration operations workspace, yesterday's Failures and Average duration (ms) for createSalesOrder on Service call statistics, and Inbound order policy state filtered on Pending (orders waiting longer than a few runs mean the job has stopped) and on Flagged. See I want to do the daily check.
  4. Ines looks for an alert on held orders and refused webshop calls. The Lattice alert events cover parked items, recurring data jobs, failed business event publishing and workflows; none fits a synchronous integration like this one. So Kai makes the webshop raise its own alert, with the ErrorCode and Message, whenever a create is refused, and Rosa activates Batch job status changed for USMF: the team hears when someone withholds or cancels the evaluation job, or when the platform withholds it because its user was disabled. A run that ends in error is not reported by that event, which the Pending check covers. See I want to be alerted when something needs me and Batch job status changed.

What changed​

  • The webshop speaks its own language. Customers and products travel as webshop numbers; only the order number comes back from Finance and Operations.
  • A timeout is harmless. Every order carries one request ID for life, so a resend returns the first result instead of a second order.
  • Doubtful prices stop before the customer sees them. The policy held both test orders, and the clean ones were confirmed within minutes without anyone touching them.
  • The access is limited. A leaked secret could post documents, but not cancel or reverse them, post across legal entities or change the Lattice setup.
  • Problems surface on the first morning. The daily check and the alerts were in place before the first real order.

For the business: the webshop went live on schedule, customers get confirmations within minutes, and pricing mistakes reach Dana instead of a customer.

Try it yourself​

In a sandbox with the USMF demo data and an application registered as in step 1 with the Integration operator role:

  1. Add SHOP on External systems, then store a key for US-001 with POST /data/LatticeCustomerCrossReferences and { "dataAreaId": "usmf", "CustomerAccount": "US-001", "ExternalSystem": "SHOP", "ExternalKey": "C5521" }, as a user that holds Integration administrator. See Use external keys.
  2. Turn on the order hold feature, set a Price hold code, a Price tolerance (%) of 10 and Auto-confirm hold-free orders, and schedule Inbound order policy evaluation in USMF.
  3. Look up D0001's sales price on the released product and send createSalesOrder with CustAccountExternalKey C5521, item D0001 and half that price. Send the same request again: the order number comes back with "Duplicate request detected".
  4. After the next run, find the order Held on Inbound order policy state. Clear the hold on Order holds and watch it turn Released, then Auto-confirmed after the following run.