SBX - Search With Button

SBX - Forum Post Title

How to upgrade extension without loosing data?

Microsoft Dynamics NAV Forum

ramesh reddy asked a question on 19 Jun 2018 2:49 AM
My Badges

Question Status

Suggested Answer

Hi All,

How do i upgrade my extension v1(NAVX) without loosing data?

i have reffered below links 

https://community.dynamics.com/nav/f/34/t/244086

https://docs.microsoft.com/en-us/dynamics-nav/extensions-upgrade-howto

and also i have below quesations.

1. NAVAPP.GETARCHIVERECREF how this function works and what is NAVAPP(installed app or Archived data app?)

2.NAVAPP.RESTOREARCHIVEDATA here also NAVAPP which one can take?

is this possible to debug upgrade code unit then how?

any other way to upgrade data for extension 1 not through AL?

Please suggest me to resolve?

Thank you

Ramesh

Reply
Mohana Yadav responded on 19 Jun 2018 8:17 AM
My Badges
Suggested Answer

do you have any table data changes between your V1 version to V2?

Reply
ramesh reddy responded on 19 Jun 2018 10:38 AM
My Badges

Hi mohana,

Thanks for the reply, data changes means?

I have uninstalled extension1 and data is archived automatically. And I have changed some code in code unit. Again created a package and installed in version 1.1.

Here in the step I am lossing my all custom tables data. I need to restore archive data to my tables when I install new version.

This is NAVX package extension from cside not AL.

Please suggest me.

Thanks

Ramesh

Reply
Suggested Answer

You need to create an Upgrade codeunit and use NAVAPP.RestoreArchiveData(XX) to restore the archived data of table with ID = XX. NAVAPP contains th archived data of the extension that you're upgrading.

Reply
ramesh reddy responded on 19 Jun 2018 11:43 AM
My Badges

Hi Stefano,

i have used NAVAPP.RestoreArchiveData(XX) in my upgrade codeunit but it's not working for me. and here NAVAPP which app should consider installed app or archived app.

Please let me know.

Thank you

Ramesh

--

Reply
Suggested Answer

NAVAPP is the archived app. Can you post the upgrade codeunit code?

Reply
ramesh reddy responded on 19 Jun 2018 1:05 PM
My Badges

Hi Stefano,

Please find below upgrade codeunit.

OBJECT Codeunit 55055 Upgrade Mgt.

{

 OBJECT-PROPERTIES

 {

   Date=19/01/16;

   Time=23:10:40;

   Modified=Yes;

   Version List=RA1.00;

 }

 PROPERTIES

 {

   OnRun=BEGIN

         END;

 }

 CODE

 {

   PROCEDURE OnNavAppUpgradePerDatabase@1100084000();

   BEGIN

   END;

   PROCEDURE OnNavAppUpgradePerCompany@1100084001();

   BEGIN

     RestoreFieldsInModifiedTables(11025000,11025999);

     RestoreAppTables(11025000,11025999);

   END;

   LOCAL PROCEDURE RestoreFieldsInModifiedTables@1100084005(FromField@1100084004 : Integer;ToField@1100084005 : Integer);

   VAR

     Field@1100084001 : Record 2000000041;

     AllObj@1100084000 : Record 2000000038;

   BEGIN

     WITH AllObj DO BEGIN

       SETRANGE("Object Type","Object Type"::Table);

       IF FINDSET THEN

         REPEAT

             Field.SETRANGE(TableNo, "Object ID");

             Field.SETRANGE("No.", FromField, ToField);

             IF NOT Field.ISEMPTY THEN BEGIN

               NAVAPP.RESTOREARCHIVEDATA("Object ID");

             END;

         UNTIL NEXT < 1;

     END;

   END;

   LOCAL PROCEDURE RestoreAppTables@1100084006(FromTableID@1100084003 : Integer;ToTableID@1100084004 : Integer);

   VAR

     AllObj@1100084005 : Record 2000000038;

   BEGIN

     WITH AllObj DO BEGIN

       SETRANGE("Object Type", "Object Type"::Table);

       SETRANGE("Object ID", FromTableID,ToTableID);

       IF FINDSET THEN

         REPEAT

           NAVAPP.RESTOREARCHIVEDATA("Object ID");

         UNTIL NEXT < 1;

     END;

   END;

   BEGIN

   END.

 }

}

Reply
ramesh reddy responded on 20 Jun 2018 6:48 AM
My Badges

Hi All,

i am getting this error when i uninstall and install same version of  NAV App.

i got this below error

Microsoft Dynamics NAV

---------------------------

Could not upgrade the NAV extension 'GS07Ext9' due to the following error: 'The following tables contain data but cannot be upgraded because the relevant upgrade

instructions are missing: 23 (Vendor), 38 (Purchase Header), 39 (Purchase Line), 120 (Purch. Rcpt. Header), 121 (Purch. Rcpt. Line), 122 (Purch. Inv. Header),

123 (Purch. Inv. Line), 291 (Shipping Agent), 312 (Purchases & Payables Setup), 7317 (Warehouse Receipt Line), 7319 (Posted Whse. Receipt Line).'.

---------------------------

OK

---------------------------

any one face this issue.

Note: This is extension V1 from CSide not from AL.

thank you

Ramesh

--

Reply
Suggested Answer

Does your extension add custom fields on that tables?

Reply
ramesh reddy responded on 20 Jun 2018 10:03 AM
My Badges

Yes, I have custom tables on that tables.

Above issue resolved when i restart the service but here is problem i am facing for up-gradation of extension.

Did you see above upgrde codeunit i have posted? any issue on this?

when i manually run that above code unit i didn't get any NAVAPP. it is showing that NAVAPP not intialized.

when this code unit will run? when publish the package or when install the package? 

can you please let me know the process of extension V1 upgrade process.

Thank you

Ramesh

--

Reply
Suggested Answer

When you install an extension, data from the previous version are copyed in a "backup table" called NAVAPP. You cannot manually run this upgrade codeunit.

For more info:

docs.microsoft.com/.../nav-app

docs.microsoft.com/.../extensions-upgrading

docs.microsoft.com/.../extensions-upgrade-howto

Check expecially this last link. I think you need also to handle the restore of the custom fields added on the standard tables by your extension.

Reply
Mohana Yadav responded on 19 Jun 2018 8:17 AM
My Badges
Suggested Answer

do you have any table data changes between your V1 version to V2?

Reply
Suggested Answer

You need to create an Upgrade codeunit and use NAVAPP.RestoreArchiveData(XX) to restore the archived data of table with ID = XX. NAVAPP contains th archived data of the extension that you're upgrading.

Reply
Suggested Answer

NAVAPP is the archived app. Can you post the upgrade codeunit code?

Reply
Suggested Answer

Does your extension add custom fields on that tables?

Reply
Suggested Answer

When you install an extension, data from the previous version are copyed in a "backup table" called NAVAPP. You cannot manually run this upgrade codeunit.

For more info:

docs.microsoft.com/.../nav-app

docs.microsoft.com/.../extensions-upgrading

docs.microsoft.com/.../extensions-upgrade-howto

Check expecially this last link. I think you need also to handle the restore of the custom fields added on the standard tables by your extension.

Reply

SBX - Two Col Forum

SBX - Migrated JS