Data upgrade script

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

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 K3 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::K3CallCenter
        where RetailChannelProfile.ChannelProfileType == 7;

    ttsCommit;
}
Additional method to existing class:
\Classes\ReleaseUpdateDB63_WHS\updateK3WHSWorkEnum
/// <summary>
///     Updates WHSRFMenuItemTable with new WHSWorkActivity base enum values
/// </summary>
[
UpgradeScriptDescriptionAttribute('Updates K3 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 updateK3WHSWorkEnum()
{
    ClassName   className   = classStr(ReleaseUpdateDB63_WHSMinorUpdateK3Retail);
    MethodName  methodName  = methodStr(ReleaseUpdateDB63_WHSMinorUpdateK3Retail, updateEnumValues);

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

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.
Join us.

Blog Tags