Skip to content

Instantly share code, notes, and snippets.

@ztirom
Created April 22, 2016 17:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ztirom/cf2d2ab4e4f32092ea9140d24f173700 to your computer and use it in GitHub Desktop.
Save ztirom/cf2d2ab4e4f32092ea9140d24f173700 to your computer and use it in GitHub Desktop.
Reset a NumberSequence in AX2012
static void ResetNumSeq(Args _args)
{
NumberSequenceTable numSeqTable;
try
{
ttsbegin;
select forUpdate * from numSeqTable
where numSeqTable.RecId == 22565432450; // RecId from NumberSequenceTable
if (numSeqTable && numSeqTable.selectForUpdate())
{
info(strFmt("Before: %1", numSeqTable.NextRec));
numSeqTable.NextRec = numSeqTable.Lowest;
if (numSeqTable.validateWrite())
numSeqTable.update();
else
throw Exception::Error;
}
else
throw Exception::Error;
ttscommit;
info(strFmt("After: %1", numSeqTable.NextRec));
}
catch (Exception::Error)
{
error("Update failed :/");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment