Data upgrade script

New class for data upgrade:
/// <summary>
///     The <c>ReleaseUpdateDB63_WHSMinorUpdateVKRetail</c> class contains upgrade scripts for the WHS area data
/// </summary>
class ReleaseUpdateDB63_WHSMinorUpdateVKRetail extends ReleaseUpdateDB
{
    #define.version(sysReleasedVersion::v63)
    #define.className(ReleaseUpdateDB63_WHSMinorUpdateVKRetail)
}

public void initPostSyncUpdateJobs()
{
    #initSyncJobsPrefix
}

/// <summary>
///     Gets the module name of an upgrade class.
/// </summary>
/// <returns>
///    The module name.
/// </returns>
/// <remarks>
///    This method must be implemented by sub classes.The module name is displayed on the cockpit form for
///    every script.
/// </remarks>
public ReleaseUpdateModule moduleName()
{
    return classId2Name(classIdGet(this));
}

/// <summary>
///     Updates WHSRFMenuItemTable with new WHSWorkActivity base enum values
/// </summary>
[
UpgradeScriptDescriptionAttribute('Updates VK Retail base enums values'),
UpgradeScriptConfigKeyAttribute(configurationKeyStr(WHSAndTMS)),
UpgradeScriptStageAttribute(ReleaseUpdateScriptStage::PostSyncUpdate),
UpgradeScriptTypeAttribute(ReleaseUpdateScriptType::StandardScript),
// Tables which data is updated
// str _tableName, boolean _create, boolean _read, boolean _update, boolean _delete, boolean _exclude = false
UpgradeScriptTableAttribute(tableStr(WHSRFMenuItemTable),   false,  true,   true,    false),
UpgradeScriptTableAttribute(tableStr(RetailChannelProfile), false,  true,   true,    false),
UpgradeScriptTableAttribute(tableStr(WHSWorkUserSession), false,  true,   true,    false)
]
public void updateEnumValues()
{
    RetailChannelProfile    retailChannelProfile;
    WHSRFMenuItemTable      wHSRFMenuItemTable;
    WHSWorkUserSession      wHSWorkUserSession;

    ttsBegin;

    // data update goes here
    update_recordSet retailChannelProfile setting ChannelProfileType = RetailChannelProfileType::VKCallCenter
        where RetailChannelProfile.ChannelProfileType == 7;

    ttsCommit;
}
Additional method to existing class:
\Classes\ReleaseUpdateDB63_WHS\updateVKWHSWorkEnum
/// <summary>
///     Updates WHSRFMenuItemTable with new WHSWorkActivity base enum values
/// </summary>
[
UpgradeScriptDescriptionAttribute('Updates VK Retail base enums values'),
UpgradeScriptConfigKeyAttribute(configurationKeyStr(WHSAndTMS)),
UpgradeScriptStageAttribute(ReleaseUpdateScriptStage::PostSync),
UpgradeScriptTypeAttribute(ReleaseUpdateScriptType::StandardScript),
// Tables which data is updated
// str _tableName, boolean _create, boolean _read, boolean _update, boolean _delete, boolean _exclude = false
UpgradeScriptTableAttribute(tableStr(WHSRFMenuItemTable),   false,  true,   true,    false),
UpgradeScriptTableAttribute(tableStr(RetailChannelProfile), false,  true,   true,    false),
UpgradeScriptTableAttribute(tableStr(WHSWorkUserSession), false,  true,   true,    false)
]
public void updateVKWHSWorkEnum()
{
    ClassName   className   = classStr(ReleaseUpdateDB63_WHSMinorUpdateVKRetail);
    MethodName  methodName  = methodStr(ReleaseUpdateDB63_WHSMinorUpdateVKRetail, updateEnumValues);

    ReleaseUpdateDB::MarkAMinorVersionScriptAsFinished(className, methodName);
}
Data upgrade script should appear in:
System administration/Setup/Checklists/Software update checklist

To reset script execution:
Delete records from \Data Dictionary\Tables\ReleaseUpdateScriptsHistory
Uncheck Finished checkbox from \Data Dictionary\Tables\ReleaseUpdateMinorScripts
Reset checklist and execute it from scratch.

 

Search

About

DaxOnline.org is free platform that allows you to quickly store and reuse snippets, notes, articles related to Dynamics AX.

Authors are allowed to set their own AdSense units and "buy me a coffee" link.
Join us.

Blog Tags