Search Results for

    Show / Hide Table of Contents

    Extending Item Tracking

    The business logic of COSMO Mobile Solution provides a robust framework for utilizing the basic item tracking functionality of Business Central within the mobile application. This documentation outlines the steps required to extend the standard solution to accommodate specific business requirements.

    Background

    The item tracking functionality is built upon standard Business Central tables such as Tracking Specification and Entry Summary. Additionally, a helper table, CCS MS Tracking Specification, replaces the temporary tables used in the standard implementation. This helper table serves as the source table for the Web Service (WS) pages (CCS MS Item Tracking Card WS and CCS MS Item Tracking List WS) and is also used to store modification logs for item tracking changes.

    Extending Source Tables with Custom Fields

    In this example, additional fields are introduced to calculate quantities: MYEXT Basic Quantity and MYEXT Quantity Multiplier. These fields are used to demonstrate how COSMO Mobile Solution handles item tracking in the mobile application.

    Extending the Source Table

    1. Extend the relevant tables with the required fields. Ensure that the field names are consistent across the Tracking Specification and CCS MS Tracking Specification tables. The business logic should only be implemented in the Tracking Specification table. The COSMO Mobile Solution framework will invoke the original validation logic when users modify the extra fields in the mobile application.

      namespace MyExtension.Inventory.Tracking;
      
      using Microsoft.Inventory.Tracking;
      
      tableextension 50010 "MYEXT Tracking Spec." extends "Tracking Specification"
      {
          fields
          {
              field(50001; "MYEXT Basic Quantity"; Decimal)
              {
                  DataClassification = CustomerContent;
                  Caption = 'Basic Quantity';
      
                  trigger OnValidate()
                  begin
                      // Custom business logic
                      Validate("Quantity (base)", "MYEXT Basic Quantity" * "MYEXT Quantity Multiplier");
                  end;
              }
      
              field(50002; "MYEXT Quantity Multiplier"; Decimal)
              {
                  DataClassification = CustomerContent;
                  Caption = 'Quantity Multiplier';
      
                  trigger OnValidate()
                  begin
                      // Custom business logic
                      Validate("Quantity (base)", "MYEXT Basic Quantity" * "MYEXT Quantity Multiplier");
                  end;
              }
          }
      }
      
      namespace MyExtension.Inventory.Tracking;
      
      using CosmoConsult.MobileSolution.BusinessLogic.Inventory.Tracking;
      
      tableextension 50011 "MYEXT MS Tracking Spec." extends "CCS MS Tracking Specification"
      {
          fields
          {
              field(50001; "MYEXT Basic Quantity"; Decimal)
              {
                  DataClassification = CustomerContent;
                  Caption = 'Basic Quantity';
      
                  trigger OnValidate()
                  begin
                      // Call back to the original validation logic
                      ValidateFieldValue("MYEXT Basic Quantity", FieldName("MYEXT Basic Quantity"));
                  end;
              }
      
              field(50002; "MYEXT Quantity Multiplier"; Decimal)
              {
                  DataClassification = CustomerContent;
                  Caption = 'Quantity Multiplier';
      
                  trigger OnValidate()
                  begin
                      // Call back to the original validation logic
                      ValidateFieldValue("MYEXT Quantity Multiplier", FieldName("MYEXT Quantity Multiplier"));
                  end;
              }
          }
      }
      
    2. Use the following subscription point to invoke the original validation logic. This is necessary because the Tracking Specification table is always temporary by design, and its data is lost after every Web Service call through OData. COSMO Mobile Solution stores item tracking data in a separate, persistent table ("CCS MS Tracking Specification") instead of the original Tracking Specification table.

      namespace MyExtension.Inventory.Tracking;
      
      using Microsoft.Inventory.Tracking;
      using CosmoConsult.MobileSolution.BusinessLogic.Inventory.Tracking;
      
      codeunit 50010 "MYEXT MS Item Tracking"
      {
          Permissions =
              tabledata "CCS MS Tracking Specification" = rm,
              tabledata "Tracking Specification" = rm;
      
          [EventSubscriber(ObjectType::Table, Table::"CCS MS Tracking Specification", 'OnValidateBaseTrackingSpecField', '', false, false)]
          local procedure CCSMSTrackingSpecification_OnValidateBaseTrackingSpecField(var _BaseTrackingSpecification: Record "Tracking Specification" temporary; _FieldName: Text; _FieldValue: Variant; var _IsHandled: Boolean)
          begin
              case _FieldName of
                  _BaseTrackingSpecification.FieldName("MYEXT Basic Quantity"):
                      begin
                          _IsHandled := true;  // Must be TRUE to avoid unhandled validation errors
                          _BaseTrackingSpecification.Validate("MYEXT Basic Quantity", _FieldValue);
                      end;
      
                  _BaseTrackingSpecification.FieldName("MYEXT Quantity Multiplier"):
                      begin
                          _IsHandled := true;  // Must be TRUE to avoid unhandled validation errors
                          _BaseTrackingSpecification.Validate("MYEXT Quantity Multiplier", _FieldValue);
                      end;
              end;
          end;
      }
      

    Extending Web Service Pages

    1. Extend the published Web Service pages to display the additional fields in the mobile application.

      namespace MyExtension.Inventory.Tracking;
      
      using CosmoConsult.MobileSolution.BusinessLogic.Inventory.Tracking;
      
      pageextension 50010 "MYEXT MS Item Tracking Card WS" extends "CCS MS Item Tracking Card WS"
      {
          layout
          {
              addlast(GroupName)
              {
                  field("MYEXT Basic Quantity"; Rec."MYEXT Basic Quantity")
                  {
                      ApplicationArea = All;
                      ToolTip = ' ';  // Tooltips are not used in the Web Service interface
                  }
      
                  field("MYEXT Quantity Multiplier"; Rec."MYEXT Quantity Multiplier")
                  {
                      ApplicationArea = All;
                      ToolTip = ' ';  // Tooltips are not used in the Web Service interface
                  }
              }
          }
      }
      
      namespace MyExtension.Inventory.Tracking;
      
      using CosmoConsult.MobileSolution.BusinessLogic.Inventory.Tracking;
      
      pageextension 50011 "MYEXT MS Item Tracking List WS" extends "CCS MS Item Tracking List WS"
      {
          layout
          {
              addlast(GroupName)
              {
                  field("MYEXT Basic Quantity"; Rec."MYEXT Basic Quantity")
                  {
                      ApplicationArea = All;
                      ToolTip = ' ';  // Tooltips are not used in the Web Service interface
                  }
      
                  field("MYEXT Quantity Multiplier"; Rec."MYEXT Quantity Multiplier")
                  {
                      ApplicationArea = All;
                      ToolTip = ' ';  // Tooltips are not used in the Web Service interface
                  }
              }
          }
      }
      
    2. Update the configuration for the CCSMSItemTrackingCardWS and CCSMSItemTrackingListWS page customizations.

      1. Open the Mobile Solution Center page.

      2. Navigate to the Page Customizations tile.

      3. Locate and select both the CCSMSItemTrackingCardWS and CCSMSItemTrackingListWS customizations.

      4. Choose the Refresh Metadata action.

        After refreshing, the newly added fields will appear at the bottom of the field list in the Card View FastTab. These fields can be configured for visibility, order, and inclusion in the List View FastTab.

    Now, the AL objects and the COSMO Mobile Solution configuration are ready to use the extended item tracking functionality.

    Additional Information about the Basic Item Tracking Solution

    The CCS MS Item Tracking codeunit includes several integration events to modify the basic item tracking implementation of COSMO Mobile Solution:

    • OnAfterTryRegisterItemTrackingLines: Triggered after the user closes the item tracking card or list in the mobile application. This event allows for additional data modifications in the database.
    • OnBeforeRefreshTrackingAvailability: Triggered before the availability of the tracked quantity is checked. This event can be used to replace the original calculation logic.
    • OnBeforeSetQtyOnSNTrackedReservationEntryParam and OnBeforeSetQtyOnSNTrackedTrackingSpec: Used for handling serial numbers with quantities other than 1, specifically for movement and item tracking.
    • OnBeforeCheckWhseReceiptHeaderDelete, OnBeforeCheckWhseReceiptLineDelete, OnBeforeCheckWhseShipmentLineDelete, and OnBeforeCheckWhseShipmentHeaderDelete: Allow overriding the default logic that prevents the deletion of warehouse receipt or shipment documents with registered tracking lines.


    Feedback
    Submit feedback for this page .

    In This Article
    Back to top 2025 © COSMO CONSULT - Data protection - Imprint