Skip to main content

MobileItemMgt220FDW

Utility codeunit for resolving items from scanned barcodes, managing item metadata, and performing unit-of-measure conversions. This is a stateful codeunit -- once an item is resolved, its properties (tracking settings, UOM, variant) are cached for subsequent calls.

Overview​

  • Object type: Codeunit
  • Object ID: 73167890
  • Access: Public
  • Namespace: Aptean.Mesh.SDUI

Resolution Strategy​

When Resolve is called with a scanned value, the codeunit attempts to identify the item using three strategies in order:

  1. Item Reference -- looks up the scanned value in the Item Reference table, prioritizing barcode-type references
  2. Item No. -- attempts a direct lookup on the Item table by item number
  3. Lot No. Information -- looks up the scanned value in Lot No. Information to reverse-resolve the item (only if exactly one match exists)

Once resolved, the item's tracking settings (lot tracking, expiration date requirements) are loaded from the Item Tracking Code.


Item Resolution Methods​

Get​

procedure Get(NewItemNo: Code[20]): Boolean

Loads an item by its exact item number. If the same item is already resolved, returns immediately without re-querying.

Parameters:

NameTypeDescription
NewItemNoCode[20]The item number to load

Returns: Boolean -- true if the item was found.


Resolve​

procedure Resolve(ScannedValue: Code[100]): Boolean

Attempts to resolve an item from a scanned barcode or entered value using the resolution strategy described above. Clears any previously resolved item state before attempting resolution.

Parameters:

NameTypeDescription
ScannedValueCode[100]The scanned barcode or manually entered value

Returns: Boolean -- true if the item was successfully resolved.

Example:

var
ItemMgt: Codeunit MobileItemMgt220FDW;
begin
if not ItemMgt.Resolve('5901234123457') then
Error('Could not identify item from scan');

Message('Resolved item: %1 - %2', ItemMgt.GetItemNo(), ItemMgt.GetDescription());
if ItemMgt.IsLotTracked() then
Message('This item requires lot tracking');
end;

Getter Methods​

All getters return cached values from the last successful Get or Resolve call.

IsItemResolved​

procedure IsItemResolved(): Boolean

Returns true if an item is currently resolved.


GetItemNo​

procedure GetItemNo(): Code[20]

Returns the resolved item number.


GetVariantCode​

procedure GetVariantCode(): Code[10]

Returns the variant code. This is populated when the item was resolved via an Item Reference or Lot No. Information that specifies a variant.


GetUnitOfMeasureCode​

procedure GetUnitOfMeasureCode(): Code[10]

Returns the unit of measure code from the item reference used during resolution. Falls back to the base unit of measure if no reference UOM was found.


GetBaseUnitOfMeasure​

procedure GetBaseUnitOfMeasure(): Code[10]

Returns the item's base unit of measure code.


IsVariantCodeExplicit​

procedure IsVariantCodeExplicit(): Boolean

Returns true if the variant code was explicitly set during resolution (from an Item Reference or Lot No. Information), as opposed to being blank by default.


GetDescription​

procedure GetDescription(): Text[100]

Returns the item's Description field. Returns blank if no item is resolved.


GetFullDescription​

procedure GetFullDescription(): Text[150]

Returns the item's Description and Description 2 concatenated with a space, truncated to 150 characters. Returns blank if no item is resolved.


IsLotTracked​

procedure IsLotTracked(): Boolean

Returns true if the item has lot-specific tracking enabled in its Item Tracking Code.


IsExpirationDateUsed​

procedure IsExpirationDateUsed(): Boolean

Returns true if the item's tracking code has Use Expiration Dates enabled. This controls whether expiration dates are tracked at all — use this to decide whether to show or hide expiration date fields in the workflow.


IsExpirationDateRequired​

procedure IsExpirationDateRequired(): Boolean

Returns true if the item's tracking code requires mandatory expiration date entry (Man. Expir. Date Entry Reqd.). A subset of IsExpirationDateUsed() — an item can use expiration dates without making entry mandatory.


IsStrictExpirationEnabled​

procedure IsStrictExpirationEnabled(): Boolean

Returns true if the item's tracking code enforces strict expiration posting (items cannot be posted after expiration).


GetNextLotNo​

procedure GetNextLotNo(): Code[50]

Generates and returns the next lot number from the item's lot number series. Raises an error if no lot number series is configured for the item.

Returns: Code[50] -- the next available lot number.


HasLotNoSeries​

procedure HasLotNoSeries(): Boolean

Returns true if the item has a lot number series configured. Use this to check before calling GetNextLotNo.


GetSelectedUOM​

procedure GetSelectedUOM(): Code[10]

Returns the currently selected unit of measure. Priority: explicitly selected UOM > reference UOM > base UOM.


GetQtyPerSelectedUOM​

procedure GetQtyPerSelectedUOM(): Decimal

Returns the quantity per unit of measure for the currently selected UOM. Returns 1 if no explicit selection has been made.


IsUOMSet​

procedure IsUOMSet(): Boolean

Returns true if a unit of measure has been explicitly set via SetSelectedUOM.


Setter Methods​

SetVariantCode​

procedure SetVariantCode(NewVariantCode: Code[10])

Overrides the variant code. Use this when the user manually selects a variant that differs from what was resolved.

Parameters:

NameTypeDescription
NewVariantCodeCode[10]The variant code to set

SetSelectedUOM​

procedure SetSelectedUOM(UOMCode: Code[10])

Sets the selected unit of measure and loads its conversion factor from the Item Unit of Measure table. Pass blank to clear.

Parameters:

NameTypeDescription
UOMCodeCode[10]The UOM code to select (blank to clear)

ClearSelectedUOM​

procedure ClearSelectedUOM()

Clears the explicitly selected UOM and resets the conversion factor.


UOM Operations​

GetDisplayQuantity​

procedure GetDisplayQuantity(
LineQty: Decimal;
LineQtyPerUOM: Decimal;
DisplayUOM: Code[10]
): Decimal

Converts a line quantity to a display quantity in a different UOM. Returns the original quantity if DisplayUOM is blank.

Parameters:

NameTypeDescription
LineQtyDecimalThe quantity in the line's UOM
LineQtyPerUOMDecimalThe line's qty-per-UOM conversion factor
DisplayUOMCode[10]The target UOM for display (blank = no conversion)

Returns: Decimal -- the converted quantity.


FormatQuantityWithUOM​

procedure FormatQuantityWithUOM(Qty: Decimal; UOMCode: Code[10]): Text

Formats a quantity and UOM code as a display string (e.g., "10 PCS"). Trailing zeros are trimmed from decimal values.

Parameters:

NameTypeDescription
QtyDecimalThe quantity to format
UOMCodeCode[10]The UOM code to append

Returns: Text -- formatted string like "10 PCS" or "2.5 KG".


FormatQuantityForDisplay​

procedure FormatQuantityForDisplay(Qty: Decimal): Text

Formats a quantity for display, trimming unnecessary trailing zeros. Whole numbers are displayed without decimals.

Parameters:

NameTypeDescription
QtyDecimalThe quantity to format

Returns: Text -- formatted quantity string.

Examples: 10 becomes "10", 2.50000 becomes "2.5", 3.14159 becomes "3.14159".


GetQtyPerUOM​

procedure GetQtyPerUOM(UOMCode: Code[10]): Decimal

Returns the quantity per unit of measure for the specified UOM code. Returns 1 if the UOM is blank or not found.

Parameters:

NameTypeDescription
UOMCodeCode[10]The UOM code to look up

Returns: Decimal -- the conversion factor.


GetQtyRoundingPrecision​

procedure GetQtyRoundingPrecision(UOMCode: Code[10]): Decimal

Returns the quantity rounding precision for the specified UOM code. Returns 0.00001 as the default if not configured.

Parameters:

NameTypeDescription
UOMCodeCode[10]The UOM code to look up

Returns: Decimal -- the rounding precision.


CalcBaseQty​

procedure CalcBaseQty(
Qty: Decimal;
UOMCode: Code[10];
QtyPerUOM: Decimal;
QtyRoundingPrecision: Decimal
): Decimal

Calculates the base quantity from a quantity in a specific UOM. Delegates to the standard BC Unit of Measure Management codeunit.

Parameters:

NameTypeDescription
QtyDecimalThe quantity to convert
UOMCodeCode[10]The source UOM code
QtyPerUOMDecimalThe conversion factor
QtyRoundingPrecisionDecimalThe rounding precision

Returns: Decimal -- the quantity in base UOM.


CalcQtyFromBase​

procedure CalcQtyFromBase(QtyBase: Decimal; QtyPerUOM: Decimal): Decimal

Converts a base quantity to a quantity in a specific UOM.

Parameters:

NameTypeDescription
QtyBaseDecimalThe base quantity to convert
QtyPerUOMDecimalThe target UOM's conversion factor

Returns: Decimal -- the converted quantity.


GetAvailableUOMs​

procedure GetAvailableUOMs(): List of [Text]

Returns a list of all UOM codes configured for the resolved item. Returns an empty list if no item is resolved.

Returns: List of [Text] -- available UOM codes.


ConvertQtyToLineUOM​

procedure ConvertQtyToLineUOM(
ScannedQty: Decimal;
ScannedUOMCode: Code[10];
LineUOMCode: Code[10];
LineQtyPerUOM: Decimal
): Decimal

Converts a scanned quantity from one UOM to the line's UOM. If the scanned UOM matches the line UOM (or is blank), returns the quantity unchanged.

Parameters:

NameTypeDescription
ScannedQtyDecimalThe quantity scanned by the user
ScannedUOMCodeCode[10]The UOM the quantity was entered in
LineUOMCodeCode[10]The warehouse activity line's UOM
LineQtyPerUOMDecimalThe line's qty-per-UOM conversion factor

Returns: Decimal -- the quantity expressed in the line's UOM.


ConvertQtyFromLineUOM​

procedure ConvertQtyFromLineUOM(
LineQty: Decimal;
LineQtyPerUOM: Decimal;
TargetUOMCode: Code[10]
): Decimal

Converts a line quantity to a target UOM. Returns the original quantity if the target UOM is blank or has a zero conversion factor.

Parameters:

NameTypeDescription
LineQtyDecimalThe quantity in the line's UOM
LineQtyPerUOMDecimalThe line's qty-per-UOM conversion factor
TargetUOMCodeCode[10]The target UOM to convert to

Returns: Decimal -- the converted quantity.


TrySelectUOM​

procedure TrySelectUOM(
SelectedValue: Text;
CurrentUOM: Code[10];
var NewUOM: Code[10]
): Boolean

Attempts to select a new UOM from a user's choice. Validates the UOM exists for the item and differs from the current UOM. If valid, updates the internal selected UOM state.

Parameters:

NameTypeDescription
SelectedValueTextThe UOM code selected by the user
CurrentUOMCode[10]The currently active UOM
NewUOMCode[10] (var)Output -- the validated new UOM code

Returns: Boolean -- true if a new UOM was selected, false if the value was invalid, not found, or same as current.

Example:

var
ItemMgt: Codeunit MobileItemMgt220FDW;
NewUOM: Code[10];
begin
if ItemMgt.TrySelectUOM('KG', 'PCS', NewUOM) then
Message('UOM changed to %1', NewUOM);
end;

Typical Usage​

The following illustrates how MobileItemMgt220FDW is used in a workflow step handler:

var
ItemMgt: Codeunit MobileItemMgt220FDW;
ScanEntryMgt: Codeunit ScanEntryMgt220FDW;
begin
// 1. Resolve item from barcode scan
if not ItemMgt.Resolve(ScannedBarcode) then
Error('Unknown item');

// 2. Check tracking requirements
if ItemMgt.IsLotTracked() then
// Prompt for lot number in next step

if ItemMgt.IsExpirationDateRequired() then
// Prompt for expiration date

// 3. Get UOM info for scan entry
UOMCode := ItemMgt.GetSelectedUOM();
QtyPerUOM := ItemMgt.GetQtyPerSelectedUOM();

// 4. Create scan entry with resolved data
ScanEntryMgt.InsertScanEntry(
ItemMgt.GetItemNo(),
LocationCode,
ItemMgt.GetVariantCode(),
SourceType, SourceSubtype, SourceID,
'', 0, SourceRefNo,
LotNo, SerialNo,
Quantity, UOMCode, QtyPerUOM,
ExpirationDate, BinCode
);
end;