OpenCore MES Try the demo

Docs Integration 6

Recipes

On this page

6.1 Inbound without duplicates

Have the caller send an Idempotency-Key per business message (the order number and its revision). Inside the script, guard on the natural key too, for a message sent again under another key:

A service's Try it tab: a lot's number sent, ERP's confirmation answered
Try it: the published service called as you, through its callers and checks; its answer below.
A service's Try it tab: a lot's number sent, ERP's confirmation answeredTry it: the published service called as you, through its callers and checks; its answer below.
const [known] = await ctx.records.list("work_order", { wo_no: ctx.input.wo_no });
if (known) { ctx.output = { id: known.id, state: known.state, existed: true }; return ctx; }

6.2 Saying no with the right field

Throw with the input it is about; a caller reads 422 with the field named, as a form does:

if (ctx.input.qty > 10000) throw Object.assign(new Error("At most 10 000 per order."), { field: "qty" });
The integration monitor's Run history: runs of the two services, from a screen and from the schedule
The monitor's Run history: every run, how it was set off, its outcome and who set it off.
The integration monitor's Run history: runs of the two services, from a screen and from the scheduleThe monitor's Run history: every run, how it was set off, its outcome and who set it off.

6.3 Down is not no

Tell a system that is down (5xx, unreachable) from one that refuses (4xx). Throw with retry: true only for the first: a trigger is retried; a refusal is final, and its words are kept.

6.4 Choosing the identity

Prefer the service's own role: what it may do is on the service, approved by the stewards of each object it touches, and does not grow when someone gives the integration user another role. Use a named user when your plant manages the outside system's rights as a person's. Use the caller only for services people call to do, faster, what they may do anyway.

6.5 Keeping a run inside the right network

Give the nodes inside the network that reaches ERP a tag (NODE_TAGS=erp) and the service runOn: "erp"; the monitor warns when no live node has the tag.