-
-
Save ztirom/cf2d2ab4e4f32092ea9140d24f173700 to your computer and use it in GitHub Desktop.
Reset a NumberSequence in AX2012
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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