Adding or Changing Unique Indexes [Dynamics AX ]

Well, I thought this information would be helpful to all of us during pre-synchronization upgrade job.

If you add a new unique index to a table, or change an existing one, it will cause problems for users when they upgrade to a new version of Microsoft Dynamics AX. This will cause a best practice error.
This error can be fixed by implementing an upgrade script called AllowDupTablenameIndexname, or DeleteDupTablenameIndexname as a pre-synchronization upgrade job.

For example, if the new unique index on MyTable is called NewUniqueIndex, the script should be called AllowDupMyTableNewUniqueIndex or DeleteDupMyTableNewUniqueIndex.
“AllowDup” scripts
Use this to temporarily disable the unique index. When you have removed conflicting fields, you need to run an upgrade script to re-enable the unique index.
“AllowDup” scripts should contain the following code.

{
DictIndex dictIndex = new DictIndex(
tablenum(TableName),
indexnum(TableName, IndexName));
;
ReleaseUpdateDB::indexAllowDup(dictIndex);
}

“DeleteDup” scriptsUse this to delete all conflicting fields.

“DeleteDup” scripts should contain the following code.

{
;
ReleaseUpdateDB::deleteDuplicatesUsingIds(
tablenum(TableName),
fieldnum(TableName, UniqueIndexField));
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: