Inbound auto-pricing and headless auto-attach on purchase lines
This page is for administrators and accounting managers who run integrations that create order lines, and for the people who watch what Earmark does with those lines. With Inbound auto-pricing on, Earmark prices a sales order line that a standard integration created, following the inbound pricing policy for the customer and sales origin. With Headless auto-attach on purchase lines on, Earmark builds the price of every new purchase order line with every vendor deal that applies, so supplier deals accrue without anyone selecting Build price. Runs: by itself, right after the order is saved (when the transaction that created the line commits). Set up by: Accounting manager. Watched by: Accounting manager, Accounts receivable manager and Accounts payable manager (the workbench rows), the order taker (lines left unpriced).
Why it exists
A deal's money reaches an order line only through a price build: Build price on the line works out the eligible deals, writes the price and turns each included deal into a commitment that accrues when the goods move. Lines that arrive through OData, data management, dual-write or Dynamics 365 Sales have nobody to select Build price. The inbound pricing policies say what should happen to them instead, customer by customer and sales origin by sales origin.
A supplier rebate on purchases works the same way: it accrues on a purchase line only when the line's price build includes the deal. Headless auto-attach builds each new purchase line with every eligible vendor deal, which is how supplier deals accrue when buyers do not build purchase lines by hand.
Neither ever stands in the way of the order. The order is saved first, the pricing runs after it, and a pricing failure is never an error on the order. Most failures leave the line unpriced with no record at all; only some leave a row on the execution exceptions workbench (see When it fails).
When it runs
- Right after the order commits. A line inserted inside a transaction (which is how every order line is inserted) is only noted at that moment. When the transaction commits, Earmark prices the noted lines. If the transaction rolls back, nothing is priced.
- In the same request. The pricing runs straight after the commit, and the request that saved the order waits for it, so an import that creates many lines takes longer to return than it would without it.
- In groups. Lines are grouped by company, at most 100 lines to a group, and each group runs in its own session.
- Sales lines only where a policy exists. If the company has no inbound pricing policy at all, its sales lines are not handed on.
There is no batch job to schedule.
Settings
| Setting | Where | Default | Effect |
|---|---|---|---|
| Inbound auto-pricing | Earmark > Setup > Earmark parameters, Price build-up tab | No | The master switch for sales lines. Off: no integration line is priced automatically, whatever policies exist, and a retry of an Inbound price build row is refused. |
| Customer deals | Earmark parameters, Modules tab | Set at setup | Must be on for sales lines to be priced. |
| Price build-up on sales lines | Earmark parameters, Price build-up tab | No | Not read by inbound auto-pricing: lines are built even while it is off. But the Price build-up FactBox on the order line stays empty and the stale price warning at posting does not run while it is off, so switch it on too. |
| Inbound pricing policies | Earmark > Setup > Inbound pricing policies | None | What happens to an integration line: Customer code (Table, Group or All) with Customer relation, Sales origin code (Table or All) with Sales origin, Action, Priority, Base price source, Effective from and Effective to. |
| Action (on a policy) | Inbound pricing policies | Do nothing | Do nothing, Propose and hold or Build and accept all eligible. See What it does. |
| Base price source (on a policy) | Inbound pricing policies | Payload, else native price | In this release both choices give the same base: the unit price on the line as it was created, that is the price the integration sent or, when it sent none, the price the order took from trade agreements. |
| Headless auto-attach on purchase lines | Earmark parameters, Vendor deals tab | No | The switch for purchase lines. On: every new purchase line in scope is built with every eligible vendor deal. |
| Vendor deals | Earmark parameters, Modules tab | Set at setup | Must be on for purchase lines to be attached. |
| Purchase price mode default | Earmark parameters, Vendor deals tab | Company default | The price mode of a purchase build when the deal names none, or while Allow per-deal price mode is off. Company default means Off-invoice for a purchase line; a Purchase price build-up deal is always Off-invoice. |
| Proposal session retention (days) | Earmark parameters, Retention tab | 30 | How long a proposal written by Propose and hold is kept. |
The settings are described in full in the configuration reference. Setting up the policies is described in Getting started and setting up Earmark.
What it does
Sales lines (inbound auto-pricing)
-
A sales line is inserted. Earmark hands it on only when all of these hold, checked from the line and its order without running any deal logic:
- the line carries the integration mark that the standard sales order line data entities set when they create it (OData, including the Excel add-in; data management; dual-write; Dynamics 365 Sales);
- Customer deals and Inbound auto-pricing are on;
- the line is not a return line: not of type return, no negative quantity, not linked to a shipment it returns, not an intercompany line;
- the order is not a return order, not an intercompany order and not a Commerce order.
The mark exists only while the entity inserts the line; it is not stored. A line entered in the order form, added by Copy from, created by custom code or by any integration that does not go through a standard sales order line entity, or added by hand later to an order an integration created, is never priced automatically.
-
The line waits for the commit. It is noted against the order's transaction; nothing else happens while the order is being saved.
-
After the commit, if the company has at least one inbound pricing policy, the noted lines are priced in groups of up to 100, each group in its own session.
-
For each line, Earmark checks again that Inbound auto-pricing is on and that the line and order are in scope, and skips a line that already has a price build.
-
It finds the policy, most specific first, and stops at the first step that finds one:
- this customer account and this sales origin;
- this customer account, all origins;
- this customer group and this sales origin;
- this customer group, all origins;
- all customers and this sales origin;
- all customers, all origins.
Within a step, the policy in effect on the date the order was created wins, highest Priority first, then the latest Effective from.
-
It applies the policy's Action.
- Do nothing, or no policy found: the line keeps the price it was created with.
- Propose and hold: Earmark writes a proposal for the line, with every eligible deal Proposed and,
for a deal that applies but cannot be used (for example its unit cannot be converted or its cap is used
up), the reason, and leaves the price alone. No Earmark page lists these held
lines, and Build price on the line works out a fresh proposal rather than opening the held one. The
held proposal can be read through the
MGCEarmarkPriceProposalsdata entity and is removed after Proposal session retention (days). - Build and accept all eligible: Earmark builds the price and accepts every eligible deal, as an order taker would with Build price and Accept. The build records Build source Inbound pricing policy, and each included deal becomes an accrual instance on the line.
-
It reports, but only some failures. Earmark treats any error the build raises as a refusal: a policy outcome, and also most real failures, such as a validation error. The line is left unpriced, no row is raised, and nothing tells anyone. Only a failure of another kind, such as a database deadlock, an update conflict or a .NET runtime error, raises an Inbound price build row (see When it fails).
Purchase lines (headless auto-attach)
- A purchase line is inserted, from any source: the purchase order form, an integration or a copy. Earmark hands it on when Vendor deals is on, Headless auto-attach on purchase lines is Yes, the line is not a return line (not of type return, no negative quantity, not intercompany) and the order is not a return order or an intercompany order. There is no integration mark and no policy: every line in scope counts, including the ones a buyer types in.
- The line waits for the commit and is then handed on in groups of up to 100 per company, each group in its own session, as for sales lines.
- For each line, Earmark checks the scope again, skips a line that already has a price build, and builds the price with every eligible vendor deal accepted. The build records Build source Conduit service.
- The price mode of each component is the deal's own when Allow per-deal price mode is on, else Purchase price mode default, else Off-invoice; a Purchase price build-up deal is always Off-invoice.
- It reports as for sales lines: any error the build raises, most real failures included, leaves the line unbuilt with no row; only a failure of another kind raises a Headless purchase attach row.
Before it can run
- Approved deals in force that apply to the line, exactly as Build price would find them, at the moment the line is saved. A line no deal reaches is not left alone: under Build and accept all eligible, and on every purchase line in scope, it still gets a build, with only the base price, and on a sales line that build locks the price. Because automatic pricing skips a line that already has a build, a deal approved later never reaches it; to bring the deal in, unbuild the line and build its price again.
- For sales lines: at least one inbound pricing policy in the company, a policy whose Action is not Do nothing for the customers you want priced, Inbound auto-pricing on and Customer deals on. Use Test inbound pricing resolution on the policies page to see which policy a customer, sales origin and date would get; it writes nothing.
- For purchase lines: Headless auto-attach on purchase lines and Vendor deals on.
- The integration uses a standard sales order line data entity. Lines inserted any other way never carry the integration mark.
- Roles. Only the Accounting manager, and the System
administrator, who can do everything, maintain the policies (on the page or through
/data/MGCEarmarkInboundPricingPolicies); the Accounting manager and the System administrator change the parameters. No role is needed for the pricing itself: it runs as part of saving the order.
What goes in and what comes out
| In | Out | |
|---|---|---|
| Sales line, Build and accept all eligible | The new line, its order, the policy, the eligible deals | A price build on the line (Build source Inbound pricing policy), the line's price written by it, one accrual instance per included deal, the Earmark line price built business event |
| Sales line, Propose and hold | The new line, the eligible and ineligible deals | A proposal (one row per deal) and no change to the line |
| Sales line, Do nothing or no policy | The new line | Nothing |
| Purchase line | The new line, the eligible vendor deals | A price build on the line (Build source Conduit service), one accrual instance per included deal (none for a Purchase price build-up deal, which accrues nothing), the Earmark line price built business event |
| Any line, on a failure | The cause | Usually nothing: the line stays unpriced. For the failures that raise one, one workbench row. The order is unchanged either way |
The failure rows read:
- Inbound price build: "The price for line %2 of order %1 could not be built automatically: %3. The order itself is unaffected and stands exactly as it was created … Fix whatever the message names and use Retry selected; the retry re-reads the inbound pricing policy, so a policy row you have since corrected is picked up, and it cannot build the line twice."
- Headless purchase attach: "Headless purchase attach failed for purchase order %1 line %2: %3".
- A line whose group's session failed before reaching it gets its own row of the same operation, whose message ends "…this line was handed to a post-commit session together with other lines, and that session failed before it reached this line, so nothing was done to it. The cause is recorded on the workbench row for the same operation raised against record %1. Fix that cause and use Retry selected on this row".
Watching it
- Earmark > Inquiries and reports > Price build-up lists every build in the company; its Build source column says Inbound pricing policy for an inbound sales build and Conduit service for a headless purchase build.
- The Price build-up FactBox on the sales order line shows the build, while Price build-up on sales lines is on.
- Earmark > Inquiries and reports > Earmark execution exceptions, filtered on the operation Inbound price build or Headless purchase attach. This shows only some failures (see When it fails).
- Lines left unpriced. For sales lines, an integration can read the Sales order lines V2 entity
(
SalesOrderLines): itsMGCEarmarkBuildNumbercolumn is empty on a line with no current build (see the entity reference). The newer sales order line entity and the purchase order line entities carry no Earmark column, so for purchase lines there is no such check; compare the lines with the Price build-up list instead. - The business event Earmark line price built, if your integration listens to it. See Earmark business events.
When it fails
A failure never refuses or changes the order. Most failures leave only an unpriced line, with no row anywhere: an order taker builds such a line by hand (see Watching it for how to find them). The failures that do leave a record leave one Open row on Earmark execution exceptions. For those:
- Read the message and fix the cause: a deal or its setup, the policy, a locked or changed line.
- Switch to the row's company (the Company column). Retry looks the line up in your current company; from another company it finds no line and marks the row Resolved without pricing anything.
- Select Retry selected. For an Inbound price build row the retry reads the policy as it is now and applies it again. While Inbound auto-pricing is off it prices nothing and warns "Inbound auto-pricing is off in company %1, so the inbound price build of sales order %2 line %3 was not retried and the row stays open. Turn on Inbound auto-pricing in the Earmark parameters and retry the row, or dismiss it." For a Headless purchase attach row the retry builds the line even if Headless auto-attach on purchase lines has been switched off since.
- For a group that failed part way, fix the cause named on the row of the first line, then retry every row of the group.
Retrying is safe. Each automatic build carries an idempotency key for its line, and a line that already has a price build is skipped, so a retry can never build a line twice. A line that no longer exists resolves its row. If nobody is going to fix the cause, Dismiss the row with a reason and let an order taker build the line by hand.
The full workbench procedure is on Earmark execution exceptions: background steps and Retry.
Effects on the rest of Earmark
- Accrual. Each accepted deal is an accrual instance on the line: it accrues when the goods ship or are received, like any other build. See Accrual event processing.
- Later changes. On a sales line, an automatic build is treated exactly as a build made by hand afterwards: it is flagged stale when the line's item, inventory dimensions, quantity, unit, price unit, invoice account, requested ship date or currency changes. A purchase line's build is never flagged stale.
- People can still act. An order taker can build a line the policy left alone, and can unbuild an automatic build like any other. A line with a build is skipped by any later automatic run, and a buildPrice call for it is refused as already built.
- Business events. Each automatic build sends Earmark line price built when Publish deal events is on and the event is activated.
- The order. Never blocked, never rolled back, whatever the pricing does.
Related
- Pricing and accruals: know what happens to lines created by an integration
- Getting started: set up inbound pricing policies
- Vendor deals and mirrors
- Page reference: Inbound pricing policies
- Page reference: Build price
- Integration developer: what you do and where
- Order taker: what you do and where · Order taker: I want to know why a purchase line was built without me
- Earmark execution exceptions: background steps and Retry
- API reference