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.
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:
/* No SYS code must exist in this method */ void startupPost() { //find the current company when the client is stared: CompanyInfo companyInfo = CompanyInfo::find(); //code that changes menu items based on company setup... }
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:
/* No SYS code must exist in this method */ void startupPost() { CompanyInfo companyInfo; Application app = new Application(); if (app.isRunningMode() && !SysModelStore::isInstallMode() && !SysCheckList_Update::isUpgradeMode()) { companyInfo = CompanyInfo::find(); //code that changes menu items based on company setup... } }
*This post is locked for comments