Skip to main content

Standard batch and periodic processes with Warden installed

Warden ships no replacement for any standard Dynamics 365 periodic process. It extends some of them by chain of command, so the standard job runs as before and Warden adds a check, a hold, a refusal or a record at a defined point. This page lists every such extension of a standard class that can run in batch or that a periodic job reaches, says what changes, and says what an operator sees.

Warden's own batch classes are documented in Warden batch framework. This page is about standard classes only.

At a glance​

Standard processStandard class → method wrappedWarden classFeature toggle consultedSection
Inventory journal posting (Check and Post)InventJournalCheckPost_Movement → run (inherited from JournalCheckPost), pre-nextMGCWardenInventJournalRoute_ExtensionJournal GovernanceInventory journal posting
InventJournalCheckPost_Movement → checkJournal, postJournalMGCWardenInventJournalBand_ExtensionJournal Governance (inside MGCWardenJournalBandGuard)
InventJournalCheckPost_Movement → postJournalMGCWardenInventJournalCheckPost_ExtensionJournal Governance
Inventory journal copyInventJournalCopy → run, both sides of nextMGCWardenInventJournalCopy_ExtensionJournal GovernanceInventory journal copy
Inventory journals clean-upInventJournalCleanUp → run, both sides of nextMGCWardenInventJournalCleanUp_Extension, with MGCWardenJournalCleanupContextJournal GovernanceInventory journals clean-up
Trade agreement journal postingPriceDiscAdmCheckPost → runFromContract (static), postJournalMGCWardenPriceDiscAdmCheckPost_ExtensionTrade Agreement Governance (default on)Trade agreement journal posting
Planned order firming, including firming from master planningReqTransPoMarkFirm → run, post-next; delegate ReqTransPoMarkFirm.createdMGCWardenReqTransPoMarkFirm_Extension; subscriber MGCWardenFirmingSubscriberOrder Guard for the gate; none for the end-of-run drainPlanned order firming
Purchase document postingPurchFormLetter → validate, runMGCWardenPurchFormLetter_ExtensionNonePurchase and sales document posting
Sales document postingSalesFormLetter → validate, validateExecutionMGCWardenSalesFormLetter_ExtensionSales Governance
Late-selection (query-driven) posting runs, single-threadedFormletterService → createParmData, post-nextMGCWardenFormletterService_ExtensionPurchase: none; sales: Sales GovernanceLate-selection posting runs
Late-selection posting runs, parallelFormletterServiceBatchTaskManager → createFormletterServiceTasks, pre-nextMGCWardenFormletterTaskMgr_ExtensionPurchase: none; sales: Sales Governance
Sales orders written by a batch task or data-management importNot an extension: detection onlyMGCWardenBatchImportContext, used by MGCWardenDuplicateDetectorSales GovernanceBatch and import detection
Document output (print management, including post-and-print)PurchPurchaseOrderController, PurchConfirmationRequestController, SalesConfirmController, SalesQuotationController, SalesQuotationConfirmationController → outputMGCWardenPurchOrderEmitGate_Extension, MGCWardenConfRequestEmitGate_Extension, MGCWardenSalesConfirmEmitGate_Extension, MGCWardenQuoteEmitGate_Extension, MGCWardenQuoteConfirmEmitGate_ExtensionPurchase: none; sales and quotation: Sales GovernanceDocument output
Workflow message processing (platform batch)Not extendedWarden workflow event handlers run there-Workflow message processing

The posting, copy, clean-up and firming classes above can all run in batch: InventJournalCopy, InventJournalCleanUp and PriceDiscAdmCheckPost extend RunBaseBatch, and ReqTransPoMarkFirm extends ReqTransPoMark, which does too; none of them overrides canGoBatch() (which returns true in RunBaseBatch), JournalCheckPost extends JournalRunBaseBatch, and the form-letter controllers are unpacked and run on the batch server (stated in MGCWardenPurchFormLetter_Extension).

Out of scope here: the warehouse mobile cycle-count extensions (MGCWardenWHSWorkExecute_Extension, MGCWardenWHSWorkExecuteDisplay_Extension, MGCWardenWHSWorkExecuteDisplayCycleCount_Extension, MGCWardenWHSWorkLineCycleCount_Extension) run on device requests, not in a periodic job; the counting journals they lead to are posted through the inventory journal posting seams below. The Auditor's report sensor on SrsReportRunController is part of read capture and is not covered here.

One rule runs through every section. A Warden catch inside a standard process is honest about where it works: a catch naming UpdateConflict or DuplicateKeyException runs inside a transaction, and every other catch does not. So where a seam is reached inside the caller's transaction, a Warden fault refuses the standard operation (fail-closed) instead of letting it through with an attestation. Each section says which case applies.

Inventory journal posting​

Standard process. Checking or posting an inventory journal (JournalCheckPost.run, which opens a transaction and calls runCheck and runPost inside it). Covers movement, loss/profit, transfer, BOM, counting, project and asset journals and ownership change; not tag counting (InventJournalCheckPost_Tag).

What Warden adds.

SeamWhenWhat it does
MGCWardenInventJournalRoute_Extension.runBefore next run(), so before the posting transactionCalls MGCWardenJournalBandGuard::routeBeforeRun: with Journal Governance on and at transaction level 0, raises any banded review the journal owes: hold, MGCWardenJournalGovState, workflow. It stands down silently when the feature is off or the level is not 0
MGCWardenInventJournalBand_Extension.checkJournalInside the posting transactionRefuses a journal missing a mandatory attachment or with a review outstanding, through checkFailed, and records the refusal out of band once per journal per day (logCheckRefusal)
MGCWardenInventJournalBand_Extension.postJournalInside the posting transactionThe same two refusals, thrown, each recorded out of band first
MGCWardenInventJournalCheckPost_Extension.postJournalInside the posting transactionRefuses a reversing journal whose reversal is not approved; see Journal reversal router

In batch. A journal posted from its form, or sent to batch from the posting dialog, reaches run at transaction level 0: MGCWardenInventJournalRoute_Extension records that Batch.AutomaticTransaction is never set for the journal stack, so the batch framework does not wrap run. The review is routed and committed, then the check refuses the journal until the review completes.

Inside another process's transaction. MGCWardenInventJournalRoute_Extension's caller census found that most inventory-journal posting entry points in the build are nested in a caller's transaction: warehouse mobile counting and transfers, ITM over/under, Rental transfers, BOM report-finish, retail kit assembly, field service and others. There routeBeforeRun stands down, nothing is routed, and the gate still refuses the journal. No approver is asked. The only thing that raises the owed review on those paths is the journal route drain; see Route drains.

What the operator sees. The review sentence from MGCWardenJournalReviewRouter::gateReason, for example "Journal X has a line costing N, which meets the T review band of B under policy P vN; it cannot post until that review completes.", or, where nothing was routed, "... and that review has not been raised. It cannot post until the review is raised and completed." The standard posting then fails with its own check-failed message. Because the check and post seams run inside the posting transaction, a Warden fault there fails the Check or Post with the platform's error and Warden records nothing.

Warden's own count consolidation posts counting journals from a clean transaction level; see Count consolidation run.

Inventory journal copy​

Standard process. The Copy function on inventory journal forms (InventJournalCopy), which is also the only native way to reverse a posted inventory journal.

What Warden adds. With Journal Governance on, a copy of a posted journal whose journal name is under an active policy with ReversalWorkflow = Yes is treated as a reversal: after the copy completes, the new journal is held and the Warden journal reversal approval is raised. Copies of unposted journals are untouched. Full detail: Journal reversal router.

In batch. Both seams run at transaction level 0, because InventJournalCopy.run opens its own transaction partway through. A copy run in batch is classified and routed in that batch task, and the workflow is originated by the account the task runs as.

What the operator sees. The copy always completes. If routing fails after the copy, a Critical exception says the reversing journal was created without a hold and can be posted ungoverned.

Inventory journals clean-up​

Standard process. InventJournalCleanUp, the periodic task that deletes posted inventory journals of the journal types ticked on its dialog. MGCWardenInventJournalCleanUp_Extension records, from the native source, that it has no days-to-keep or cutoff parameter: it deletes every posted journal of the selected types, through raw SQL or a SysDaDeleteStatement with skipDataMethods(true). So InventJournalTable.delete(), and Warden's posted-immutability delete gate on it (MGCWardenInventJournalTable_Extension), never fire for this job.

What Warden adds.

  1. Before next run(), with Journal Governance on, snapshots the posted journals whose journal name is under an active policy with Posted immutability (MGCWardenJournalCleanupContext::isGoverned), up to a cap of 20,000 (snapshotCap).
  2. After next run(), checks each snapshotted journal and writes a RetentionCleanup event-log row ("Retention cleanup deletion") only for those actually gone: "Posted journal X (journal name N) was removed by the native inventory-journal cleanup batch (InventJournalCleanUp), run by WP-…. Housekeeping deletion - NOT a user delete ...". The account is named by subject reference. Then one summary row.
  3. If the cap was reached, the summary says the evidence is partial and a Warning exception (ControlOutage) asks you to run the clean-up in smaller slices.

MGCWardenJournalCleanupContext::isNativeCleanupContext lets the delete gate recognize a row-level delete made under the clean-up task (by batch-task class, or by the call stack for a foreground run), never by user name. In this build that carve-out is defense in depth, because the native job does not delete row by row.

In batch. InventJournalCleanUp.run has no top-level transaction, so both Warden blocks run at level 0 and their catches work. A snapshot failure files a Warning exception and the clean-up runs without evidence; an evidence failure after the run files an Error exception. The clean-up is never blocked by Warden.

Trade agreement journal posting​

Standard process. Posting a classic trade agreement (price/discount) journal, PriceDiscAdmCheckPost. Its run() posts by calling runFromContract, and so do several other callers (vendor catalog product release, demo data, retail kit configurator, and the Lattice price service).

What Warden adds. With Trade Agreement Governance on:

  • runFromContract (every caller): unless the contract is check-only, re-evaluates the journal against the price-guard policy in force (MGCWardenTAPostGuard::evaluateAtPost) before native's transaction opens. A Route-posture finding gates the journal, places the hold and raises the trade agreement approval, then refuses; a Block-posture breach is refused outright with no approval.
  • postJournal (inside native's transaction): a latch that refuses a journal already gated (MGCWardenTAGate::isGated), recorded out of band before the throw.

In batch. The batch path calls runFromContract with no transaction open, so the verdict, gate, hold, approval and evidence are committed before the refusal, and a Warden fault there lets the posting go ahead with an UngovernedAction row. Callers that open their own transaction first (vendor catalog product release, retail kit configurator) get the refusal recorded out of band, but nothing is gated or routed.

What the operator sees. For example "Trade agreement journal X is under an open Warden price governance gate ... Posting is refused until the approval completes." or "Trade agreement journal X is gated by Warden price governance; posting is blocked until the gate is released." A gated journal that nobody routes is recovered by the trade agreement route drain; see Route drains and Trade agreement approval sweep.

Planned order firming​

Standard process. Firming planned purchase orders, from the planned orders page or from master planning's auto-firming (MGCWardenReqTransPoMarkFirm_Extension records that ReqCalc calls ReqTransPoMarkFirm.run() directly).

What Warden adds.

  • The gate, through MGCWardenFirmingSubscriber on the ReqTransPoMarkFirm.created delegate, inside the per-order firming transaction: with Order Guard on, MGCWardenFirmingGate::evaluateFirmedPurchaseOrder puts an over-threshold purchase order on a hold of type Firming (Firming approval) and creates a firming request (MGCWardenFirmingRequest). When firming adds a planned order to a purchase order it created earlier in the run, the delegate fires again for that order and the gate measures the whole order again: an order now over the threshold, or grown since its approval, is held and its approval owed (decided 2026-11-16). The workflow activation is deferred out of that transaction.
  • The end-of-run drain, MGCWardenReqTransPoMarkFirm_Extension.run, after next run(): calls MGCWardenFirmingRouteDrainBatch::drainDeferredRoutes, which raises the deferred firming approvals at transaction level 0. It has no feature test and refuses to run inside a transaction.

In batch. With Abort if errors set, native wraps the whole firming loop in one transaction; the drain still runs after it commits. If firming is nested inside a larger transaction, or a parallel child finishes after its parent, the drain stands down and the scheduled firming route drain raises the approvals instead. The end-of-run drain is an accelerator; the scheduled drain is the guarantee. See Route drains.

What the operator sees. Firming completes. When the end-of-run drain moved something, the infolog shows "Warden firming route drain (end of firming run): N firming approval(s) raised, M escalated to the exception workbench, K not attempted ..."; it is silent otherwise. If the drain fails: "Warden could not drain the deferred firming approvals at the end of this firming run; the scheduled firming route drain will raise them." A fault in Warden's own writes inside the firming transaction is not catchable there: it fails that order's firming, or the whole run when Abort if errors is set, and Warden records nothing.

Purchase and sales document posting​

Standard process. Posting purchase documents (purchase order confirmation, confirmation request, receipts list, product receipt, vendor invoice, invoice approval journal) and sales documents (confirmation, picking list, packing slip, invoice), interactively, in batch, or through PurchFormLetter.update() / SalesFormLetter.update() from code, entities and integrations.

What Warden adds. Two seams per family, evaluated once per attempt (wardenAttemptEvaluated):

FamilyInteractive dialogBatch, service and codeToggle
PurchasePurchFormLetter.validatePurchFormLetter.run, before nextNone: a held purchase order is refused whatever Order Guard says
SalesSalesFormLetter.validateSalesFormLetter.validateExecutionSales Governance

The decision is the posting gate's (MGCWardenPurchPostingGate, MGCWardenSalesFulfilmentGate): an open hold refuses every governed status; a new finding at invoicing is routed for after-the-fact approval rather than refused. Before refusing, the purchase gate drains the delta routes the order owes, so the approver's work item exists when the user is told the order is held. See Purchase order change and delta re-approval.

In batch. The batch server unpacks the controller and calls run() directly, so validate() never runs there; the second seam is the one that gates batch posting. The flag is not packed, so the batch run is evaluated afresh. Both seams record that the batch framework does not wrap run() in a transaction for these stacks, so the catch works on the batch path. Inside a caller's own transaction (point of sale, CDX, warehouse work completion and other callers named in the class summaries) the drain stands down, the refusal is recorded through the side-connection writer, and a Warden fault refuses the posting.

What the operator sees. In the infolog or batch log, for example "Purchase order X is under a Warden governance hold. Product receipt is gated until the approval completes or the hold is released. ...". For sales, Warden's sentence is put in the infolog first, then native throws its own posting-stopped error, so the batch log carries the cause.

Late-selection posting runs​

Standard process. A posting run whose documents are chosen by a selection query when the run executes (late selection, FormLetterContract.parmLateSelection / FormLetter.lateSelection). On such a run the controller holds no single order, so the per-document seams above skip it.

What Warden adds. MGCWardenLateSelectionGate, called from two seams that never both fire on one run:

  • single-threaded: MGCWardenFormletterService_Extension.createParmData, after next, once the parm rows exist and before anything posts;
  • parallel: MGCWardenFormletterTaskMgr_Extension.createFormletterServiceTasks, before next, after the parm-data tasks finish and before any posting task is added to the batch job.

It evaluates every selected document through the existing per-family gate and, if any is held, refuses the whole run: nothing posts. Purchase runs are governed regardless of toggles; sales runs only with Sales Governance on.

What the operator sees. One error per held document, then "Warden refused this posting run in full: H of N selected documents are under a governance hold, so NOTHING was posted. Held: … Approve or release the documents named above, or take them out of the selection, and post the run again. Reposting the same selection unchanged will be refused identically." Each held document also gets its own posting-refusal row in the governance event log.

Batch and import detection​

MGCWardenBatchImportContext is not an extension. It answers one question: is this code running for a batch task (BatchHeader::getCurrentBatchTask()) or a data-management import (DmfEntityWriter or DMFEntityWriterTasks on the call stack), rather than for a person? Its only caller is MGCWardenDuplicateDetector::recordFinding. When a sales order with a duplicate customer requisition is saved under a Warn policy in such a run, the warning has no reader, so Warden also files a Warning exception (ControlOutage): "Duplicate customer requisition R accepted under Warn posture on order S ... during an unattended batch or import run: the warning had no reader. The order was NOT blocked ...". It never relaxes a Block policy. The duplicate check runs with Sales Governance on. A detection fault inside the order write's transaction refuses the order save.

Document output​

The five output wrappers stop a governed document (purchase order confirmation, confirmation request, sales order confirmation, quotation, quotation confirmation) being printed, filed or sent while the order or quotation is held, including when the document is printed as part of a posting (post-and-print). The purchase gates drain owed delta routes first and consult no toggle; the sales and quotation gates test Sales Governance. A refusal throws, after recording the refusal on a writer chosen by transaction level; inside a caller's posting transaction it refuses that posting too. The operator sees, for example, "Purchase order X is under a Warden governance hold, so Warden refused to print or send the purchase order confirmation document. ...".

Workflow message processing​

Warden does not extend, schedule or configure the platform's workflow message processing. Its approval outcomes depend on it: MGCWardenApproverOfRecord and MGCWardenWorkflowActor record that SysWorkflowQueue::invokeWorkflowEventHandler calls Warden's workflow event handlers (completed, canceled and the rest) while SysWorkflowMessageQueueManager dispatches the workflow message queue, under the message-processing batch job's account. So the hold release and state change that follow an approval happen when that job processes the queue. Warden names the person who acted through MGCWardenWorkflowActor rather than the batch account.