InstallationMicrosoft Dynamics NAV Changes

Microsoft Dynamics NAV Changes

Code Changes on Standard Objects

In this chapter an overview of the code changes made to the standard NAV objects that have been changed by Sana Commerce is given. Note, that these changes are also included in the Sana Commerce fob files, therefore these changes only have to be made manually, when other third party components are installed in the same objects.
 
Codeunit 1 - Application management 
 
New global variable: 
Name Type Subtype
SCNAS Codeunit SC - NAS Message Handler 
 
NASHandler procedure
New local variable:
Name Type Subtype
SCOptions Record SC - Setup
 
 
The NASHandler method code changes:
 
Original Code:
  IF CGNASStartedinLoop = FALSE THEN
    CASE Parameter OF
      'OSYNCH','JOBQUEUE':
        BEGIN
          IF NOT JobQueueSetup.GET THEN BEGIN
            JobQueueSetup.INIT;
            JobQueueSetup.INSERT;
          END;
          IF NOT JobQueueSetup."Job Queue Active" THEN BEGIN
            JobQueueSetup.VALIDATE("Job Queue Active",TRUE);
            JobQueueSetup.MODIFY;
          END;
          CODEUNIT.RUN(CODEUNIT::"Job Queue Dispacher");
        END;
    END;
New Code:
  // START,10/20/2009,SC
  //IF CGNASStartedinLoop = FALSE THEN Original code is commented
  IF CGNASStartedinLoop = FALSE THEN BEGIN
    SCOptions.GET;
 
    CASE Parameter OF
      'OSYNCH','JOBQUEUE':
        BEGIN
          IF NOT JobQueueSetup.GET THEN BEGIN
            JobQueueSetup.INIT;
            JobQueueSetup.INSERT;
          END;
          IF NOT JobQueueSetup."Job Queue Active" THEN BEGIN
            JobQueueSetup.VALIDATE("Job Queue Active",TRUE);
            JobQueueSetup.MODIFY;
          END;
          CODEUNIT.RUN(CODEUNIT::"Job Queue Dispacher");
        END;
 
      'SC':
        BEGIN
          SCNAS.SetConnectionOptions(SCOptions."Single Service Port",SCOptions."Single Service Secure");
          SCNAS.RUN;
        END;
 
      'SCCATALOG':
        BEGIN
          SCNAS.SetConnectionOptions(SCOptions."Catalog Service Port",SCOptions."Catalog Service Secure");
          SCNAS.RUN;
        END;
 
      'SCCUSTOMER':
        BEGIN
          SCNAS.SetConnectionOptions(SCOptions."Customer Service Port",SCOptions."Customer Service Secure");
          SCNAS.RUN;
        END;
 
      'SCORDER':
        BEGIN
          SCNAS.SetConnectionOptions(SCOptions."Order Service Port",SCOptions."Order Service Secure");
          SCNAS.RUN;
        END;
    END;
  END;
  // END,10/20/2009,SC
 
Codeunit 60 - Sales-Calc. Discount
 
CalculateInvoiceDiscount procedure
New local variable:
Name Type Subtype
InvDiscBaseAmount Decimal  
CalcInvoiceDiscount Boolean  
PromotionDiscountPercent Decimal  
 
The CalculateInvoiceDiscount method code changes:
Original Code:
  IF CustInvDiscRecExists(SalesHeader."Invoice Disc. Code") THEN BEGIN
    IF InvDiscBase <> ChargeBase THEN
      CustInvDisc.GetRec(
        SalesHeader."Invoice Disc. Code",SalesHeader."Currency Code",CurrencyDate,InvDiscBase);
 
    SalesHeader."Invoice Discount Calculation" := SalesHeader."Invoice Discount Calculation"::"%";
    SalesHeader."Invoice Discount Value" := CustInvDisc."Discount %";
    IF NOT TemporaryHeader THEN
      SalesHeader.MODIFY;
 
    TempVATAmountLine.SetInvoiceDiscountPercent(
      CustInvDisc."Discount %",SalesHeader."Currency Code",
      SalesHeader."Prices Including VAT",SalesSetup."Calc. Inv. Disc. per VAT ID",
      SalesHeader."VAT Base Discount %");
 
    SalesLine2.SetSalesHeader(SalesHeader);
    SalesLine2.UpdateVATOnLines(0,SalesHeader,SalesLine2,TempVATAmountLine);
  END;
New Code:
  // START,09/22/2010,SC
  CalcInvoiceDiscount := FALSE;
  // END,09/22/2010,SC
  IF CustInvDiscRecExists(SalesHeader."Invoice Disc. Code") THEN BEGIN
    IF InvDiscBase <> ChargeBase THEN
      CustInvDisc.GetRec(
        SalesHeader."Invoice Disc. Code",SalesHeader."Currency Code",CurrencyDate,InvDiscBase);
 
    SalesHeader."Invoice Discount Calculation" := SalesHeader."Invoice Discount Calculation"::"%";
    SalesHeader."Invoice Discount Value" := CustInvDisc."Discount %";
 
  // START,09/22/2010,SC
    CalcInvoiceDiscount := TRUE;
  END;
  IF (((SalesHeader."Sana Promotion Discount Type" <> SalesHeader."Sana Promotion Discount Type"::" ") AND
    (SalesHeader."Sana Promotion Discount Value" > 0)) OR (SalesHeader."Sana Promotion Discount Amount" > 0)) THEN BEGIN
    CalcInvoiceDiscount := TRUE;
    InvDiscBaseAmount := TempVATAmountLine.GetTotalInvDiscBaseAmount(FALSE,'');
 
    IF InvDiscBaseAmount = 0 THEN
      PromotionDiscountPercent := 0
    ELSE IF (SalesHeader."Sana Promotion Discount Type" = SalesHeader."Sana Promotion Discount Type"::"Fixed Amount") THEN
      PromotionDiscountPercent := SalesHeader."Sana Promotion Discount Value" / InvDiscBaseAmount * 100
    ELSE
      PromotionDiscountPercent := SalesHeader."Sana Promotion Discount Value";
 
    IF (PromotionDiscountPercent + CustInvDisc."Discount %") > 100 THEN
      PromotionDiscountPercent := 100 - CustInvDisc."Discount %";
    IF SalesHeader."Currency Code" = '' THEN
      Currency.InitRoundingPrecision
    ELSE
      Currency.GET(SalesHeader."Currency Code");
    SalesHeader."Sana Promotion Discount Amount" :=
      ROUND(PromotionDiscountPercent * InvDiscBaseAmount / 100,Currency."Amount Rounding Precision");
  END;
 
  IF CalcInvoiceDiscount THEN BEGIN
  // END,09/22/2010,SC
 
    IF NOT TemporaryHeader THEN
      SalesHeader.MODIFY;
 
    TempVATAmountLine.SetInvoiceDiscountPercent(
    // START,09/22/2010,SC
    // CustInvDisc."Discount %",SalesHeader."Currency Code",
      CustInvDisc."Discount %" + PromotionDiscountPercent,SalesHeader."Currency Code",
    // END,09/22/2010,SC
      SalesHeader."Prices Including VAT",SalesSetup."Calc. Inv. Disc. per VAT ID",
      SalesHeader."VAT Base Discount %");
 
    SalesLine2.SetSalesHeader(SalesHeader);
    SalesLine2.UpdateVATOnLines(0,SalesHeader,SalesLine2,TempVATAmountLine);
  END;
 
Codeunit 80 - Sales-Post
 
OnRun procedure
New local variable:
Name Type Subtype
OrderImportInfo Record SC - Order Import Information
 
The OnRun procedure code changes:

Original Code:
    ServItemMgt.CopyReservationEntry(SalesHeader);

    IF ("Document Type" = "Document Type"::Invoice) AND
       (NOT SalesSetup."Shipment on Invoice")
    THEN
      ServItemMgt.CreateServItemOnSalesInvoice(SalesHeader);

  END;

New Code:
    ServItemMgt.CopyReservationEntry(SalesHeader);

    IF ("Document Type" = "Document Type"::Invoice) AND
       (NOT SalesSetup."Shipment on Invoice")
    THEN
      ServItemMgt.CreateServItemOnSalesInvoice(SalesHeader);

    // START,12/16/2010,SC
    IF OrderImportInfo.GET(SalesHeader."Document Type",SalesHeader."No.") THEN BEGIN
      OrderImportInfo."Modified Date" := CURRENTDATETIME;
      OrderImportInfo.MODIFY;
    END;
    // END,12/16/2010,SC

  END;

 
Table 27 - Item 
 
Function Code
OnModify "Last Date/Time Modified" := CURRENTDATETIME; // 03/25/2010,SC
UpdateSCLastDateModified // START,03/25/2010,SC
"Last Date/Time  Modified" := CURRENTDATETIME;
MODIFY;
// END,03/25/2010,SC
 
Table 30 - Item Translation
 
Function Code
OnInsert // START,03/25/2010,SC
IF Item.GET("Item No.") THEN
  Item.UpdateSCLastDateModified;
// END,03/25/2010,SC
OnModify // START,03/25/2010,SC
IF Item.GET("Item No.") THEN
  Item.UpdateSCLastDateModified;
// END,03/25/2010,SC
OnDelete // START,03/25/2010,SC
IF Item.GET("Item No.") THEN
  Item.UpdateSCLastDateModified;
// END,03/25/2010,SC
 
Table 37 - Sales Line
 
New global variables: 
Name Type
DoNotUpdateUnitPrice Bool
DoNotCheckItemAvailability Bool
 
New methods: 
 
SetDoNotUpdateUnitPrice(UpdateUnitPrice : Boolean)
DoNotUpdateUnitPrice := UpdateUnitPrice;
 
SetDoNotCheckItmeAvailability(CheckItemAvailability : Boolean)
DoNotCheckItemAvailability := CheckItemAvailability;
 
Added code to the methods:
Method Code
UpdateUnitPrice //START,10/20/2009,SC
IF DoNotUpdateUnitPrice THEN
  EXIT;
//END,10/20/2009,SC
CheckItemAvailable //START,10/20/2009,SC
IF DoNotCheckItemAvailability THEN
  EXIT;
//END,10/20/2009,SC
 
Table 5715 - Item Substitution
 
Function Code
OnInsert //START,03/25/2010,SC
IF Type = Type::Item THEN
  IF Item.GET("No.") THEN
    Item.UpdateSCLastDateModified;
//END,03/25/2010,SC
OnModify //START,03/25/2010,SC
IF Type = Type::Item THEN
  IF Item.GET("No.") THEN
    Item.UpdateSCLastDateModified;
//END,03/25/2010,SC
OnDelete IF Interchangeable THEN
  IF CONFIRM(Text001 + Text002) THEN
    DeleteInterchangeableItem(Type,"No.","Variant Code","Substitute Type","Substitute No.","Substitute Variant Code")
  ELSE
    IF ItemSub.GET(
      "Substitute Type",
      "Substitute No.",
      "Substitute Variant Code",
      Type,
      "No.",
      "Variant Code")
    THEN BEGIN
      ItemSub.Interchangeable := FALSE;
      //START,03/25/2010,SC
      //ItemSub.MODIFY;
      ItemSub.MODIFY(TRUE);
      //END,03/25/2010,SC
    END;
...
//START,03/25/2010,SC
IF Type = Type::Item THEN
  IF Item.GET("No.") THEN
    Item.UpdateSCLastDateModified;
//END,03/25/2010,SC
CreateInterchangeableItem ItemSub.Type := "Substitute Type";
ItemSub."No." := "Substitute No.";
ItemSub."Variant Code" := "Substitute Variant Code";
ItemSub."Substitute Type" := Type;
ItemSub."Substitute No." := "No.";
ItemSub."Substitute Variant Code" := "Variant Code";
IF Type = Type::"Nonstock Item" THEN BEGIN
    NonStockItem.GET("No.");
    ItemSub.Description := NonStockItem.Description;
END ELSE BEGIN
    Item.GET("No.");
    ItemSub.Description := Item.Description;
END;
ItemSub.Interchangeable := TRUE;
IF ItemSub.FIND THEN
    // START,03/25/2010,SC
    //ItemSub.MODIFY
    ItemSub.MODIFY(TRUE)
    // END,03/25/2010,SC
ELSE
    // START,03/25/2010,SC
    //ItemSub.INSERT;
    ItemSub.INSERT(TRUE);
    // END,03/25/2010,SC
DeleteInterchangeableItem ItemSub.Type := XSubstType;
ItemSub."No." := XSubstNo;
ItemSub."Variant Code" := XSubstVariantCode;
ItemSub."Substitute Type" := XType;
ItemSub."Substitute No." := XNo;
ItemSub."Substitute Variant Code" := XVariantCode;
IF ItemSub.FIND THEN BEGIN
  ItemSub.CALCFIELDS(ItemSub.Condition);
  IF ItemSub.Condition THEN BEGIN
    SubCondition.SETRANGE(Type,XType);
    SubCondition.SETRANGE("No.",XNo);
    SubCondition.SETRANGE("Variant Code",XVariantCode);
    SubCondition.SETRANGE("Substitute Type",XSubstType);
    SubCondition.SETRANGE("Substitute No.",XSubstNo);
    SubCondition.SETRANGE("Substitute Variant Code",XSubstVariantCode);
    SubCondition.DELETEALL;
  END;
  ItemSub.DELETE;
  Interchangeable := FALSE;

  // START,03/25/2010,SC
  IF Item.GET(XSubstNo) THEN
    Item.UpdateSCLastDateModified;
  // END,03/25/2010,SC
END;

 
Table 5722 - Item Category
 
New text constant:
Name ConstValue
Text11123302 You cannot delete %1 because there are one or more items that include this item category.
 
Function Code
OnDelete
ProductGroup.SETRANGE("Item Category Code",Code);
// START,08/30/2010,SC
// ProductGroup.DELETEALL; //Original code is commented
ProductGroup.DELETEALL(TRUE);
// END,08/30/2010,SC
 
// START,03/25/2010,SC
Item.RESET;
Item.SETCURRENTKEY("Item Category Code","Product Group Code");
Item.SETRANGE("Item Category Code",Code);
IF NOT Item.ISEMPTY THEN
  ERROR(Text11123302,Code);
// END,03/25/2010,SC
OnRename // START,03/25/2010,SC
Item.RESET;
Item.SETCURRENTKEY("Item Category Code","Product Group Code");
Item.SETRANGE("Item Category Code",xRec.Code);
IF Item.FINDSET THEN
  REPEAT
    Item.UpdateSCLastDateModified;
  UNTIL Item.NEXT = 0;
// END,03/25/2010,SC
 
Table 5723 - Product Group
 
New text constant:
Name ConstValue
Text11123302 You cannot delete %1 because there are one or more items that include this product group.
 
Function Code
OnDelete // START,08/30/2010,SC
IF Code <> '' THEN BEGIN
  Item.RESET;
  Item.SETCURRENTKEY("Item Category Code","Product Group Code");
  Item.SETRANGE("Item Category Code","Item Category Code");
  Item.SETRANGE("Product Group Code",Code);
  IF NOT Item.ISEMPTY THEN
    ERROR(Text11123302,Code);
END;
// END,08/30/2010,SC
OnRename // START,03/25/2010,SC
Item.RESET;
Item.SETCURRENTKEY("Item Category Code","Product Group Code");
Item.SETRANGE("Item Category Code",xRec.Code);
IF Item.FINDSET THEN
  REPEAT
    Item.UpdateSCLastDateModified;
  UNTIL Item.NEXT = 0;
// END,03/25/2010,SC

Table 7002 - Sales Price
 
Function Code
OnInsert ...
// START,03/25/2010,SC
IF Item.GET("Item No.") THEN
  Item.UpdateSCLastDateModified;
// END,03/25/2010,SC
OnModify // START,03/25/2010,SC
IF Item.GET("Item No.") THEN
  Item.UpdateSCLastDateModified;
// END,03/25/2010,SC
OnDelete // START,03/25/2010,SC
IF Item.GET("Item No.") THEN
  Item.UpdateSCLastDateModified;
// END,03/25/2010,SC
 
Form(Page) 41 - Sales Quote
 
New global variable:
Name Type
SanaCustomerNo Text[50]
 
Function Code
Form - OnAfterGetRecord ...
//START,17/03/2010,SC
IF "Sell-to Customer No." <> '' THEN
  IF Customer.GET("Sell-to Customer No.") THEN
    SanaCustomerNo := Customer."Sana Customer No.";
//END,17/03/2010,SC
 
Form(Page) 42 - Sales Order
 
New global variable:
Name Type
SanaCustomerNo Text[50]
 
Function Code
Form - OnAfterGetRecord ...
//START,17/03/2010,SC
IF "Sell-to Customer No." <> '' THEN
  IF Customer.GET("Sell-to Customer No.") THEN
    SanaCustomerNo := Customer."Sana Customer No.";
//END,17/03/2010,SC
 
Form(Page) 5401 - Item Variants
 
New procedure added:
Function Code
UpdateItemDate // START,03/25/2010,SC
IF Item.GET("Item No.") THEN
  Item.UpdateSCLastDateModified;
// END,03/25/2010,SC
Form - OnInsertRecord(BelowxRec : Boolean) : Boolean UpdateItemDate; //03/25/2010,SC
Form - OnModifyRecord : Boolean UpdateItemDate; //03/25/2010,SC
 
NAV 2009 SP1 (Standard or PFS) specific change
 
Table 37 - Sales Line

The CalcVATAmountLines method code changes:
Method Code
CalcVATAmountLines IF SalesSetup."Invoice Rounding" THEN BEGIN
   //START,12/21/2009,SC
   CustPostingGroup.GET(SalesHeader."Customer Posting Group");
   //Original code is commented
   //Cust.GET(SalesHeader."Bill-to Customer No.");
   //CustPostingGroup.GET(Cust."Customer Posting Group");
   //END,12/21/2009,SC
 END;
 
Pebblestone Fashion module specific change
 
Table 36 - Sales Header 
 
Name Type
TemporarySalesHeaderUsed Bool
 
New methods:
 
SetTemporarySalesHeader(useTemporarySalesHeader : Boolean)
TemporarySalesHeaderUsed := useTemporarySalesHeader;
 
IsTemporarySalesHeader() : Boolean
EXIT(TemporarySalesHeaderUsed);
 
Changed methods:
 
Method Code changes
Field 6 No. - OnValidate
Change:
SalesHeader.GET("Document Type","Document No.");
 
To:
IF SalesHeader.GET("Document Type","Document No.") THEN BEGIN
//  SalesHeader.GET("Document Type","Document No.");

END;
CalcVatAmountLines Change:
  IF SalesSetup."Invoice Rounding" THEN BEGIN
    SalesLine3.COPYFILTERS(SalesLine);
    RoundingLineInserted := (SalesLine3.COUNT <> SalesLine.COUNT) AND NOT SalesLine."Prepayment Line";
  END;
 
To:
  IF SalesSetup."Invoice Rounding" THEN BEGIN
    SalesLine3.COPYFILTERS(SalesLine);
    RoundingLineInserted := (SalesLine3.COUNT <> SalesLine.COUNT) AND NOT SalesLine."Prepayment Line";
    IF IsTemporarySalesHeader() THEN
      RoundingLineInserted := FALSE;
  END;
PfsCreatePrepackLines Change:
IF (NOT CombinedWarning) AND (PrepackValue <> 0) THEN
    CombinedWarning := PfsMatrixControl.CombineItemCheckAvail(TargetRec);
 
To:
IF (NOT PfsCalledFromReplacement) AND (NOT CombinedWarning) AND (PrepackValue <> 0) THEN
    CombinedWarning := PfsMatrixControl.CombineItemCheckAvail(TargetRec);
 
Table 11006173 - PfsTranslation
 
New procedure added:
Function Code
UpdateItem //START,03/25/2010,SC
IF Table = DATABASE::Item THEN
  IF Item.GET("Key 1") THEN
    Item.UpdateSСLastDateModified;
IF Table = DATABASE::"PfsItem Vert Component" THEN
  IF Item.GET("Key 1") THEN
    Item.UpdateSСLastDateModified;
IF Table = DATABASE::"PfsItem Horz Component" THEN
  IF Item.GET("Key 1") THEN
    Item.UpdateSСLastDateModified;
//END,03/25/2010,SC
OnInsert UpdateItem; //03/25/2010,SC
OnModify UpdateItem; //03/25/2010,SC
OnDelete UpdateItem; //03/25/2010,SC

Form(Page) 11006110 - PfsItem Vert components
 
New procedure added:
Function Code
UpdateItemDate //START,03/25/2010,SC
IF Item.GET("Item No.") THEN
  Item.UpdateSСLastDateModified;
//END,03/25/2010,SC
Form - OnInsertRecord(BelowxRec : Boolean) : Boolean UpdateItemDate; //03/25/2010,SC
Form - OnModifyRecord : Boolean UpdateItemDate; //03/25/2010,SC
Form - OnDeleteRecord : Boolean UpdateItemDate; //03/25/2010,SC
 
Form(Page) 11006111 - PfsItem Horz components
 
New procedure added:
Function Code
UpdateItemDate //START,03/25/2010,SC
IF Item.GET("Item No.") THEN
  Item.UpdateSСLastDateModified;
//END,03/25/2010,SC
Form - OnInsertRecord(BelowxRec : Boolean) : Boolean UpdateItemDate; //03/25/2010,SC
Form - OnModifyRecord : Boolean UpdateItemDate; //03/25/2010,SC
Form - OnDeleteRecord : Boolean UpdateItemDate; //03/25/2010,SC
 
InstallationMicrosoft Dynamics NAV Changes