Objects4NAV

Upgrade Code Generation Tool for NAV 2015

Upgrade Code Generation Tool for NAV 2015


MVP_FullColor_ForScreenDoing a data transfer means that you need to compare the tables of the old version and the new version and where you have mismatch you have to take some action. The data transfer is build on the new upgrade methods in NAV 2015 by Microsoft.

We have the MergeTool that is used to compare and merge code and a lot of other cool things. This tool does the table and field comparison and builds the upgrade code based on the selected actions.

UpgradeMenu

This tool imports exported object files into a table version. Then I can compare two table versions and get all the difference listed. I also import the CRONUS tables for each version to make sure that I am not comparing built-in fields.

TableVersions2015

I give the comparison an identification and select the source and destination versions. Then I hit Compare. Within seconds I get the result.

CompareResult2015

I have got to make decisions on what to do with modified and deleted tables. I can list all the tables and check the fields comparison.

Compare36

I can select both step 1 and step 2 actions for each table. For new fields I can select a source field from the source table. The example I show here is the sales header table. I choose in step 1 to copy all the needed fields to a temporary table. The tool will find the next available upgrade table automatically. In step 2 I choose to move the data from the temporary table into the destination version. I can ask that a new field will get a value from another field in the temporary table.

The best part is yet to come. To really save some work I make the tool create all the needed NAV upgrade objects. I get all the upgrade tables with all fields.

OBJECT Table 50000 Temp Sales Header
{
  OBJECT-PROPERTIES
  {
    Date=04.08.14;
    Time=12:00:00;
    Version List=UPGW18.00.00;
  }
  PROPERTIES
  {
  }
  FIELDS
  {
    { 1   ;   ;Document Type       ;Option        ;OptionString=[Quote,Order,Invoice,Credit Memo,Blanket Order,Return Order] }
    { 2   ;   ;Sell-to Customer No.;Code20         }
    { 3   ;   ;No.                 ;Code20         }
    { 4   ;   ;Bill-to Customer No.;Code20         }
    { 5   ;   ;Bill-to Name        ;Text50         }
    { 6   ;   ;Bill-to Name 2      ;Text50         }
    { 7   ;   ;Bill-to Address     ;Text50         }
    { 8   ;   ;Bill-to Address 2   ;Text50         }
    { 9   ;   ;Bill-to City        ;Text30         }
    { 10  ;   ;Bill-to Contact     ;Text50         }
    { 11  ;   ;Your Reference      ;Text35         }
    { 12  ;   ;Ship-to Code        ;Code10         }
    { 13  ;   ;Ship-to Name        ;Text50         }
    { 14  ;   ;Ship-to Name 2      ;Text50         }
    { 15  ;   ;Ship-to Address     ;Text50         }
    { 16  ;   ;Ship-to Address 2   ;Text50         }
    { 17  ;   ;Ship-to City        ;Text30         }
    { 18  ;   ;Ship-to Contact     ;Text50         }
    { 19  ;   ;Order Date          ;Date           }
    { 20  ;   ;Posting Date        ;Date           }
    { 21  ;   ;Shipment Date       ;Date           }
    { 22  ;   ;Posting Description ;Text50         }
    { 23  ;   ;Payment Terms Code  ;Code10         }
    { 24  ;   ;Due Date            ;Date           }
    { 25  ;   ;Payment Discount %  ;Decimal        }
    { 26  ;   ;Pmt. Discount Date  ;Date           }
    { 27  ;   ;Shipment Method Code;Code10         }
    { 28  ;   ;Location Code       ;Code10         }
    { 29  ;   ;Shortcut Dimension 1 Code;Code20    }
    { 30  ;   ;Shortcut Dimension 2 Code;Code20    }
    { 31  ;   ;Customer Posting Group;Code10       }
    { 32  ;   ;Currency Code       ;Code10         }
    { 33  ;   ;Currency Factor     ;Decimal        }
    { 34  ;   ;Customer Price Group;Code10         }
    { 35  ;   ;Prices Including VAT;Boolean        }
    { 37  ;   ;Invoice Disc. Code  ;Code20         }
    { 40  ;   ;Customer Disc. Group;Code20         }
    { 41  ;   ;Language Code       ;Code10         }
    { 43  ;   ;Salesperson Code    ;Code10         }
    { 45  ;   ;Order Class         ;Code10         }
    { 47  ;   ;No. Printed         ;Integer        }
    { 51  ;   ;On Hold             ;Code3          }
    { 52  ;   ;Applies-to Doc. Type;Option        ;OptionString=[ ,Payment,Invoice,Credit Memo,Finance Charge Memo,Reminder,Refund] }
    { 53  ;   ;Applies-to Doc. No. ;Code20         }
    { 55  ;   ;Bal. Account No.    ;Code20         }
    { 57  ;   ;Ship                ;Boolean        }
    { 58  ;   ;Invoice             ;Boolean        }
    { 59  ;   ;Print Posted Documents;Boolean      }
    { 62  ;   ;Shipping No.        ;Code20         }
    { 63  ;   ;Posting No.         ;Code20         }
    { 64  ;   ;Last Shipping No.   ;Code20         }
    { 65  ;   ;Last Posting No.    ;Code20         }
    { 66  ;   ;Prepayment No.      ;Code20         }
    { 67  ;   ;Last Prepayment No. ;Code20         }
    { 68  ;   ;Prepmt. Cr. Memo No.;Code20         }
    { 69  ;   ;Last Prepmt. Cr. Memo No.;Code20    }
    { 70  ;   ;VAT Registration No.;Text20         }
    { 71  ;   ;Combine Shipments   ;Boolean        }
    { 73  ;   ;Reason Code         ;Code10         }
    { 74  ;   ;Gen. Bus. Posting Group;Code10      }
    { 75  ;   ;EU 3-Party Trade    ;Boolean        }
    { 76  ;   ;Transaction Type    ;Code10         }
    { 77  ;   ;Transport Method    ;Code10         }
    { 78  ;   ;VAT Country/Region Code;Code10      }
    { 79  ;   ;Sell-to Customer Name;Text50        }
    { 80  ;   ;Sell-to Customer Name 2;Text50      }
    { 81  ;   ;Sell-to Address     ;Text50         }
    { 82  ;   ;Sell-to Address 2   ;Text50         }
    { 83  ;   ;Sell-to City        ;Text30         }
    { 84  ;   ;Sell-to Contact     ;Text50         }
    { 85  ;   ;Bill-to Post Code   ;Code20         }
    { 86  ;   ;Bill-to County      ;Text30         }
    { 87  ;   ;Bill-to Country/Region Code;Code10  }
    { 88  ;   ;Sell-to Post Code   ;Code20         }
    { 89  ;   ;Sell-to County      ;Text30         }
    { 90  ;   ;Sell-to Country/Region Code;Code10  }
    { 91  ;   ;Ship-to Post Code   ;Code20         }
    { 92  ;   ;Ship-to County      ;Text30         }
    { 93  ;   ;Ship-to Country/Region Code;Code10  }
    { 94  ;   ;Bal. Account Type   ;Option        ;OptionString=[G/L Account,Bank Account] }
    { 97  ;   ;Exit Point          ;Code10         }
    { 98  ;   ;Correction          ;Boolean        }
    { 99  ;   ;Document Date       ;Date           }
    { 100 ;   ;External Document No.;Code35        }
    { 101 ;   ;Area                ;Code10         }
    { 102 ;   ;Transaction Specification;Code10    }
    { 104 ;   ;Payment Method Code ;Code10         }
    { 105 ;   ;Shipping Agent Code ;Code10         }
    { 106 ;   ;Package Tracking No.;Text30         }
    { 107 ;   ;No. Series          ;Code10         }
    { 108 ;   ;Posting No. Series  ;Code10         }
    { 109 ;   ;Shipping No. Series ;Code10         }
    { 114 ;   ;Tax Area Code       ;Code20         }
    { 115 ;   ;Tax Liable          ;Boolean        }
    { 116 ;   ;VAT Bus. Posting Group;Code10       }
    { 117 ;   ;Reserve             ;Option        ;OptionString=[Never,Optional,Always] }
    { 118 ;   ;Applies-to ID       ;Code50         }
    { 119 ;   ;VAT Base Discount % ;Decimal        }
    { 120 ;   ;Status              ;Option        ;OptionString=[Open,Released,Pending Approval,Pending Prepayment] }
    { 121 ;   ;Invoice Discount Calculation;Option;OptionString=[None,%,Amount] }
    { 122 ;   ;Invoice Discount Value;Decimal      }
    { 123 ;   ;Send IC Document    ;Boolean        }
    { 124 ;   ;IC Status           ;Option        ;OptionString=[New,Pending,Sent] }
    { 125 ;   ;Sell-to IC Partner Code;Code20      }
    { 126 ;   ;Bill-to IC Partner Code;Code20      }
    { 129 ;   ;IC Direction        ;Option        ;OptionString=[Outgoing,Incoming] }
    { 130 ;   ;Prepayment %        ;Decimal        }
    { 131 ;   ;Prepayment No. Series;Code10        }
    { 132 ;   ;Compress Prepayment ;Boolean        }
    { 133 ;   ;Prepayment Due Date ;Date           }
    { 134 ;   ;Prepmt. Cr. Memo No. Series;Code10  }
    { 135 ;   ;Prepmt. Posting Description;Text50  }
    { 138 ;   ;Prepmt. Pmt. Discount Date;Date     }
    { 139 ;   ;Prepmt. Payment Terms Code;Code10   }
    { 140 ;   ;Prepmt. Payment Discount %;Decimal  }
    { 151 ;   ;Quote No.           ;Code20         }
    { 160 ;   ;Job Queue Status    ;Option        ;OptionString=[ ,Scheduled for Posting,Error,Posting] }
    { 161 ;   ;Job Queue Entry ID  ;GUID           }
    { 165 ;   ;Incoming Document Entry No.;Integer }
    { 480 ;   ;Dimension Set ID    ;Integer        }
    { 825 ;   ;Authorization Required;Boolean      }
    { 827 ;   ;Credit Card No.     ;Code20         }
    { 1200;   ;Direct Debit Mandate ID;Text35      }
    { 5048;   ;Doc. No. Occurrence ;Integer        }
    { 5050;   ;Campaign No.        ;Code20         }
    { 5051;   ;Sell-to Customer Template Code;Code10 }
    { 5052;   ;Sell-to Contact No. ;Code20         }
    { 5053;   ;Bill-to Contact No. ;Code20         }
    { 5054;   ;Bill-to Customer Template Code;Code10 }
    { 5055;   ;Opportunity No.     ;Code20         }
    { 5700;   ;Responsibility Center;Code10        }
    { 5750;   ;Shipping Advice     ;Option        ;OptionString=[Partial,Complete] }
    { 5753;   ;Posting from Whse. Ref.;Integer     }
    { 5790;   ;Requested Delivery Date;Date        }
    { 5791;   ;Promised Delivery Date;Date         }
    { 5792;   ;Shipping Time       ;DateFormula    }
    { 5793;   ;Outbound Whse. Handling Time;DateFormula }
    { 5794;   ;Shipping Agent Service Code;Code10  }
    { 5800;   ;Receive             ;Boolean        }
    { 5801;   ;Return Receipt No.  ;Code20         }
    { 5802;   ;Return Receipt No. Series;Code10    }
    { 5803;   ;Last Return Receipt No.;Code20      }
    { 7001;   ;Allow Line Disc.    ;Boolean        }
    { 7200;   ;Get Shipment Used   ;Boolean        }
    { 9000;   ;Assigned User ID    ;Code50         }
  }
  KEYS
  {
    {    ;Document Type,No.     ;Clustered=Yes }
  }
  FIELDGROUPS
  {
  }
  CODE
  {

    BEGIN
      {
        ¸Dynamics.is Upgrade Table
      }
    END.
  }
}

The codeunit required to make the data manipulation.

OBJECT Codeunit 50000 Upgrade CRONUSRto
{
  OBJECT-PROPERTIES
  {
    Date=04.08.14;
    Time=12:00:00;
    Version List=UPGW18.00.00;
  }
  PROPERTIES
  {
    Subtype=Upgrade;
    OnRun=BEGIN
          END;

  }
  CODE
  {
    VAR
      DividerTxt@1000 : TextConst 'ENU=..';
      DataUpgradeMgt@1001 : Codeunit 9900;

    [CheckPrecondition]
    PROCEDURE CheckPreconditions@2();
    BEGIN
    END;

    [TableSyncSetup]
    PROCEDURE GetTableSyncSetup@3(VAR TableSynchSetup@1000 : Record 2000000135);
    BEGIN
      // The purpose of this method is to define how old and new tables will be available for dataupgrade

      // The method is called at a point in time where schema changes have not yet been synchronized to
      // the database so tables except virtual tables cannot be accessed

      // TableSynchSetup."Table ID":
      // Id of the table with schema changes (i.e the modified table).

      // TableSynchSetup."Upgrade Table ID":
      // Id of table where old data will be available in case the selected TableSynchSetup.Mode option is one of Copy or Move , otherwise 0

      // TableSynchSetup.Mode:
      // An option indicating how the data will be handled during synchronization
      // Check: Synchronize without saving data in the upgrade table, fails if there is data in the modified field/table
      // Copy: Synchronize with saving data in the upgrade table, the modified table contains data in matching fields
      // Move: Synchronize with moving the data in the upgrade table,the changed table is empty; the upgrade logic is handled only by application code
      // Force: Synchronize without saving data in the upgrade table, disregard if there is data in the modified field/table

      DataUpgradeMgt.SetTableSyncSetup(DATABASE::"Sales Header",DATABASE::"Temp Sales Header",TableSynchSetup.Mode::Copy);
      DataUpgradeMgt.SetTableSyncSetup(DATABASE::"Posting Exch. Column Def",0,TableSynchSetup.Mode::Force);
    END;

    [Upgrade]
    PROCEDURE MoveSalesHeader@5();
    VAR
      TempSalesHeader@1000 : Record 50000;
      SalesHeader@1001 : Record 36;
    BEGIN
      WITH TempSalesHeader DO BEGIN
        IF FINDSET THEN
          REPEAT
            "SalesHeader".GET("Document Type","No.");
            "SalesHeader"."Direct Debit Mandate ID" := "Direct Debit Mandate ID";
            "SalesHeader".MODIFY;
          UNTIL NEXT = 0;
        DELETEALL;
      END;
    END;

    [Upgrade]
    PROCEDURE MarkObjectsForDeletion@4000000();
    BEGIN
      DataUpgradeMgt.MarkTableForDeletion(DATABASE::"Temp Sales Header");
    END;

    BEGIN
      {
        ¸Dynamics.is upgrade codeunit
      }
    END.
  }
}

Use this link for 80% discount if you have already bought the 2013 version.

One thought on “Upgrade Code Generation Tool for NAV 2015

  1. Pingback: Sellfy.com – get into it… | Gunnar's Blog

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.