Number sequence error when starting the Upgrade checklist

Last week we solved a rather annoying issue that popped up in a clean ready-for-upgrade installation. After following the steps in the “AOD code upgrade checklist”, we suddenly saw the error ‘The number sequence for party records is not set.’. It appeard after we’ve imported the ISV, VAR and USR models. After the error is shown, the upgrade checklist is not displayed again.

AOD code upgrade checklist

Checklist in question: AOD code upgrade checklist.
Checklist AOT name: SysCheckList_UpgradeCode.
Database: Empty database with ‘Register database for upgrade‘ enabled during installation.
Error appearance: When the client is started after the ‘Import ISV upgraded layer model(s) into new model store‘ step was executed.

The problem:
It turns out the offending code was in the ISV model in the startupPost() method on the Info class.

To see an example of how the startupPost() can be used, take a look at this detailed post by Nayyar Siddiqi. Like Nayyar’s solution our ISV model has a piece of code changes application behaviour during startup. Inside the startupPost() method was a find method that selects the current company and adjusts the menu’s shown based on the company’s setup.

The code in the Info class:

  1. /*
  2. No SYS code must exist in this method
  3. */
  4. void startupPost()
  5. {
  6.     //find the current company when the client is stared:
  7.     CompanyInfo companyInfo = CompanyInfo::find();
  8.     //code that changes menu items based on company setup...
  9. }

The problem with this is of course that a ready-for-upgrade installation does not contain any data. While trying to access the record in the CompanyInfo table, the application tries to make a new record in the DirPartyTable. Since it is an empty installation, no number sequence has been setup for the DirPartyTable, and the error is thrown.


The solution in the Info class:
To resolve this issue, you first need to check if the find call is made in a ‘normal’ environment, or an environment in install or upgrade mode, before you do any method calls to access data.

Simply add a check to make sure the application is in running mode, and not in install mode or busy starting the upgrade mode:

  1. /*
  2. No SYS code must exist in this method
  3. */
  4. void startupPost()
  5. {
  6.     CompanyInfo companyInfo;
  7.     Application app = new Application();
  9.     if (app.isRunningMode() && !SysModelStore::isInstallMode() && !SysCheckList_Update::isUpgradeMode())
  10.     {
  11.         companyInfo = CompanyInfo::find();
  12.         //code that changes menu items based on company setup...
  13.     }
  14. }

One comment

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre lang="" line="" escaped="" cssfile="">