Skip to main content

Duplicate requisition sweep

Re-scans Warden's customer requisition index for sales orders that share a customer requisition (the customer's PO number) without a reason-coded override, and files a native audit case for each new finding. It sweeps sales orders, not purchase orders: the "PO" in wording such as duplicate customer PO is the customer's own purchase order number, held in SalesTable.PurchOrderFormNum.

At a glance​

Batch classMGCWardenDuplicateSweepBatch (RunBaseBatch; caption Warden duplicate requisition sweep). The scan itself is MGCWardenDuplicateDetector::sweepScoped
Menu itemMGCWardenDuplicateSweepMenuItem, label Warden duplicate requisition sweep
Menu pathSystem administration → Setup → Warden duplicate requisition sweep
Run historySystem administration → Setup → Duplicate requisition sweep runs (MGCWardenDuplicateSweepRuns), which also has a button for the menu item
Who may run itPrivilege MGCWardenDuplicateSweepPriv (Run the Warden duplicate requisition sweep), in duty MGCWardenPolicyActivationDuty, in role Warden controls owner (MGCWardenControlsOwner). The run history page and the API operation MGCWardenBatchService.runDuplicateSweep are on the same privilege. The privilege cannot register the overrides that suppress findings
Feature toggleWarden Sales Governance (MGCWardenSalesGovFeature). With it off the run stands down: it writes a Skipped run record and examines nothing
Company scopePer legal entity, unless an active policy asks for cross-company detection; then one run scans every legal entity's index rows (see Company scope)
Overlap guardYes. It is one of the six classes in MGCWardenBatchOverlapGuard
Scheduled by defaultNo. Nothing in the product creates a batch job for it
RecurrenceYou choose. No recurrence is stated in code or docs; see Configuration and scheduling options
Setup-gap rulesNone watch this sweep or its schedule

Purpose and business justification​

Warden checks for a duplicated customer requisition when a sales order is created and when its customer or customer requisition changes (MGCWardenDuplicateDetector::check). The policy posture decides what happens: Warn records it, Block refuses the save. That check cannot see:

  • orders whose customer and requisition have not changed since before a duplicate-detection policy became active;
  • orders saved while Sales Governance was switched off;
  • duplicates saved under Warn, which were recorded but not escalated.

The sweep looks at all of these under the same rule, including the same override test (isSuppressedByOverride), and turns each unsuppressed duplicate pair into a native audit case that someone has to work. This batch runs the scan.

How and when it is triggered​

  • Manually, from the menu item or from the button on Duplicate requisition sweep runs.
  • As a batch job, if you submit it to the batch framework with a recurrence from the same dialog. Nothing in Warden does this for you.
  • Through the API, MGCWardenBatchService.runDuplicateSweep(customerAccount, maxIndexRows, resumeFromLastRun). See Warden batch framework.

Configuration and scheduling options​

Dialog fields​

FieldDefaultMeaning
Customer accountBlankBlank sweeps every customer. A value restricts the run to one customer's index rows, which gives a slice whose scope is provable in one pass
Maximum index rows25,000 (#DefaultMaxIndexRows)Ceiling on index rows scanned. Must be 1 to 1,000,000 (#AbsoluteMaxIndexRows); validate() refuses anything else
Resume a capped runYesYes continues above the index row where the last Partial run for the same customer filter stopped. No restarts at the top of the index every run

The three values are packed (pack() / unpack(), version 1). If they cannot be restored, RunBase falls back to initParmDefault(). A cap of zero or out of range at run time falls back to 25,000 (effectiveCap()).

Policy settings that shape the run​

The run's population comes from active, effective MGCWardenSalesGovPolicy rows that apply to sales orders (Applies to Sales order or Both) and whose Duplicate detection posture is not Off:

Policy fieldEffect on the sweep
Duplicate detection postureAny policy with a posture other than Off switches detection on. If none does, the run closes Skipped
Duplicate lookback (days)The widest value across those policies is used. Index rows older than that are not scanned. Zero means no age limit. A policy created starts at 365; older policies may still hold 0, and one such policy widens the whole run
Cross-company duplicate checkIf any of those policies sets it, the run scans every legal entity (detectionIsCrossCompany)

The lookback is measured on MGCWardenCustReqIndex.OrderDate, which is the date the order was first indexed, not a date on the order.

Scheduling​

There is no parameter on MGCWardenParameters for this sweep, and no batch group is set in code. The interval is your decision. The trade-offs:

  • The interval is the delay between a duplicate the at-entry check did not stop and the audit case that makes somebody look at it.
  • The cost grows with the index. The index keeps a row for every order that ever carried a customer requisition, and a lookback of 0 scans all of it. The cap bounds one run; with resumption on, successive runs work through the index.
  • Two schedules of this batch must not overlap. The overlap guard refuses the later task, so an overlapping schedule produces a stream of Skipped runs. Space schedules out or chain them as dependent tasks of one batch job.

What it does​

run()
|-- Sales Governance off? --> Skipped run, event row, info line; stop
|-- another sweep task executing? --> Skipped run naming it, event row, warning; stop
|-- resumeFrom = last Partial run's cursor (same filter), else 0
|-- createRun() own transaction; run row in Running
|-- MGCWardenDuplicateDetector::sweepScoped(filter, cap, resumeFrom)
| no detecting policy? -> detectionActive = false
| for each index row above the cursor, in RecId order, until the cap:
| find a partner row with the same customer + requisition
| override on either order? -> count suppressed
| reporting row already has a case? -> count already filed
| else: file native audit case; stamp SweepCaseRef; DuplicateDetected event row
|-- closeRun() Failed / Skipped / Partial / Completed
'-- anything escapes --> failRun(): run Failed + Error exception
  1. Feature check. With MGCWardenSalesGovFeature off, recordFeatureOff() writes a Skipped run. Filing cases with the feature off would raise findings about orders the interactive check was not warning anyone about, and a filed case does not go away.
  2. Overlap guard. MGCWardenBatchOverlapGuard::blockingTask(this) is asked before the run record is opened. If another task of this class is executing, recordOverlapRefusal() writes a Skipped run whose summary is the guard's refusal text naming the running task, writes a PolicySweep event row and a warning() line, and stops. The cursor is not read or moved.
  3. Resume point. With Resume a capped run = Yes, resumePoint() reads the newest run for the same customer filter that is not Skipped. If it was Partial, the scan resumes above its LastScannedRecId. Any other status (including Failed, which does not know how far it got) starts at the top.
  4. Run record. createRun() inserts a MGCWardenDuplicateSweepRun row (RunId prefix DUPSW) in Running, with the filter, cap, resume cursor and a parameter snapshot that states whether the run covers this legal entity only or all of them. The requester is named by subject reference.
  5. Scan (sweepScoped). Rows of MGCWardenCustReqIndex above the cursor, in RecId order, within the lookback and the customer filter, are scanned until the cap. For each row the partner seek looks at the whole index, not just the slice:
    • in single-company scope, a pair is reported once, by the lexically earlier sales order number;
    • in cross-company scope, sales order numbers are not unique, so the pair is reported by the lower index RecId. A pair is then:
    • suppressed when either order carries an override for that customer and requisition (MGCWardenDuplicateOverride);
    • already filed when the reporting row's SweepCaseRef is set, so no second case is filed;
    • otherwise a new finding: MGCWardenAuditCaseFiler::fileFromSweep files a native case, the reporting row's SweepCaseRef is stamped with the case RecId in its own transaction, and a DuplicateDetected event row is written.
  6. Case filing. In one transaction fileFromSweep finds or creates the case category Warden duplicate sweep (CaseCategoryType::Audit), takes a case ID from the native case number sequence (CaseDetailForm::numRefCaseId()), inserts a CaseDetail with the full finding in Memo and the customer's party, and inserts a CaseAssociation per sales order. It writes a DiffRecorded event row against the case. If filing fails it returns 0: the finding stays in the event log only, the index row is left unstamped on purpose, and the next run tries again.
  7. Close. closeRun() picks the status: Failed if the scan did not complete, Skipped if no policy asks for detection, Partial if the cap was reached, otherwise Completed. Only a Completed run says NOTHING FOUND or NOTHING NEW FOUND. It writes the counts, a PolicySweep event row on every outcome, an audit evidence store entry (DuplicateRequisitionSweep, template DuplicateSweepCompleted) and an info line. A Partial run also files a Warning ControlOutage.

Transactions​

The run holds no transaction of its own. The run row, each case filing, each SweepCaseRef stamp and the run close are separate short transactions. Inside a transaction only a catch naming UpdateConflict or DuplicateKeyException runs; every other catch does not. The scan's catch and the filer's catch therefore run because the batch is at transaction level 0. A failed filing is isolated to its pair; a failure elsewhere in the scan ends the scan, which the run records as Failed with the counts reached so far.

Concurrency​

Two sweeps could both read an unstamped index row before either stamps it and file one pair as two cases. The overlap guard closes this for batch task against batch task:

  • the later task yields to one claimed earlier; two claimed in the same second are ordered by task RecId, so exactly one proceeds;
  • the caller's own task is excluded, so a scheduled run does not refuse itself;
  • the guard cannot see an interactive run or an API run, because neither is a batch task. Two such runs at once remain possible.

The API operation asks a stricter question: it refuses while a task of this class is executing in any company.

Company scope​

A run is scoped to the legal entity it runs in unless detectionIsCrossCompany() answers Yes. Then it reads every entity's index rows. For the overlap guard, a task in another company counts as an overlap when cross-company detection is on in either company, or when the other company cannot be entered. Two residuals are recorded in the code: overrides are read in the executing company only, and findings, cases and event rows are written in the executing company whichever companies the pair spans.

Idempotency​

Re-runs do not file a second case for the same pair: the reporting row's SweepCaseRef is the guard, and it lives in the detector so every caller gets it. maintainIndex clears SweepCaseRef when an order's customer or requisition changes, because the order is then in a different duplication. The run record's Already filed count shows the pairs a run re-examined and stayed silent about.

Dependencies and prerequisites​

  • Warden Sales Governance switched on. See Getting started.
  • An active, effective sales governance policy for sales orders with Duplicate detection posture other than Off.
  • The native case ID number sequence in the company, because each case draws its ID from it. A filing that fails is recorded and retried by the next run.
  • A populated requisition index. MGCWardenSalesTable_Extension maintains MGCWardenCustReqIndex on every sales order insert and update, whether or not the feature is on. Nothing back-fills it: an order not saved since Warden was installed has no index row and is not scanned.
  • Overrides registered from the sales order (MGCWardenDuplicateOverrideAction) for duplicates that are legitimate.

Inputs and outputs​

ReadsWrites
MGCWardenCustReqIndexMGCWardenDuplicateSweepRun (one row per run, including Skipped and Failed runs; no line table)
MGCWardenSalesGovPolicy (detection, lookback, cross-company)MGCWardenCustReqIndex.SweepCaseRef on the reporting row
MGCWardenDuplicateOverrideNative cases: CaseDetail, CaseAssociation, and the CaseCategoryHierarchyDetail row WRD-DUPREQ (description Warden duplicate sweep) when missing
Previous MGCWardenDuplicateSweepRun (resume cursor)MGCWardenEventLog: DuplicateDetected per new finding, DiffRecorded per case filed (or per failed filing), PolicySweep per run
Batch (overlap guard)Execution exceptions (see Errors)
An audit evidence store entry per completed run
One infolog line; a warning() on an overlap refusal

Logging and monitoring​

  • Duplicate requisition sweep runs shows each run's scope and outcome. The page is read-only. Read Status and the scanned and examined counts before the finding count: zero findings is the same number for a clean estate, a capped run and a run that examined nothing. The counts are rows scanned, pairs examined, findings reported, cases filed, suppressed by override and already filed, with the lookback used and the resume cursor.
  • Execution exceptions (System administration → Setup → Execution exceptions) and the Governance event log (System administration → Setup → Governance event log).
  • The native cases themselves, under the case category WRD-DUPREQ (description Warden duplicate sweep). Cases filed before 2026-11-08 sit under Warden dup: the old name was longer than the 10 characters the category field holds.
  • Batch job history for the info or warning line.
  • No setup-gap rule reports that this sweep is unscheduled or stale.

Run records are purged by retention cleanup after OperationalRetentionDays (365 on a new parameters record; zero keeps them). A run still Running is never purged, and neither is the newest run for each customer filter, whatever its age, because the next run reads its cursor.

Errors, recovery and troubleshooting​

What happenedWhat you seeWhat to do
Feature offRun Skipped; summary says the feature is offNothing, or switch it on and run again
No policy asks for detectionRun Skipped; summary NO SCOPESet a duplicate detection posture on a policy if you want the sweep
Overlap refusedRun Skipped; summary names the running task; warning() in the batch logNothing for a one-off. Refused every time means two schedules overlap: space them or chain them
Cap reachedRun Partial; Warning ControlOutage naming the stop rowRun again with resumption on until a run is Completed, or run in customer slices
Case filing failedWarning on the workbench; a DiffRecorded fallback event row; the finding counts as reported, not filedFix the cause (for example the case number sequence); the next run files it
Scan interruptedRun Failed with the rows reached; Error from the detector (Duplicate requisition sweep failed)Fix the cause and run again; a resumed run starts at the top after a Failed run
Whole run failedRun Failed; Error ControlOutageRead the exception, fix the cause, run again

A Failed run's cursor is never used, so re-running is safe: at worst the next run re-scans rows, and already-filed pairs are not filed again. A run killed mid-flight stays in Running; nothing closes it later.

A task row left at Executing by a server that died reads as running and refuses every other sweep task until the platform's dead-task cleanup resets it. The refusal text names the task.

Impact on other functionality​

  • The sweep blocks nothing. It places no hold and refuses no save. It files cases that someone has to work.
  • Cases are permanent business records naming a customer and its orders. That is why the sweep stands down with the feature off and why overlapping runs are refused.
  • Locks. Each stamp updates one index row in a short transaction. maintainIndex reads the same row with pessimisticlock when an order is saved, so a save and a stamp on the same row queue rather than conflict.
  • If the sweep never runs, duplicates the at-entry check did not stop are visible only as Warn entries in the event log, and no case is filed.