BCQuality rule · xmlportAL Developmentofficial - Microsoftderived - from the source, no model text

The `Import` argument of `Xmlport.Run` must match the XMLport's `Direction`

Xmlport.Run(Number [, RequestWindow] [, Import] [, Record]) takes an optional Import argument that says whether the XMLport imports or exports, and its default is true.

Rule on GitHub · microsoft layer · xmlport · BC all · tier official · derived

Description

Xmlport.Run(Number [, RequestWindow] [, Import] [, Record]) takes an optional Import argument that says whether the XMLport imports or exports, and its default is true. When the XMLport’s Direction property is Import or Export, the argument must agree with that direction or the call fails at run time. The consequence is easy to miss: running an export-only XMLport as Xmlport.Run(Id, false) leaves Import at its default of true, which contradicts Direction = Export. The call compiles, and the mismatch appears only when the code runs.

The argument selects the direction only when Direction is Both and no request page is shown. With a request page, it sets the default of the direction option the user sees.

Best Practice

When calling Xmlport.Run on an XMLport with Direction = Export, pass false for Import explicitly. For Direction = Import, the default is already correct; passing true documents the intent. For Direction = Both, always pass the argument so the direction does not depend on a default.

See sample: xmlport-run-import-argument-must-match-direction.good.al.

Anti Pattern

Xmlport.Run(Xmlport::"Customer Export", false); against an XMLport declared with Direction = Export. The author suppressed the request page and assumed the declared direction would be used; the omitted third argument defaults to import and the call raises a run-time error. Reviewer signal: a two-argument Xmlport.Run whose target XMLport is export-only.

Do not report a two-argument call when the target’s Direction is Import, and do not infer the direction from the XMLport’s name when its definition is not available.

See sample: xmlport-run-import-argument-must-match-direction.bad.al.

References

Xmlport.Run method and Direction property.

Examples

Changed by


From microsoft/BCQuality at aaaf6c1, MIT License, Copyright (c) 2026 Microsoft Corporation (license).