Thursday, January 21, 2016

Reversing Number sequence Ax 2012

public void revSequenceByOne(ItemGroupId _groupId)
{
NumberSequenceTable     numberSeqTableRev,numberSeqLastRec;
InventItemGroup         invItemGroup;
str                     autonumber;
     
          ttsBegin;
          invItemGroup = InventItemGroup::find(_groupId);
     
          if (invItemGroup && invItemGroup.NumberSequenceCode)
          {
              autonumber = invItemGroup.NumberSequenceCode;
              numberSeqTableRev      = NumberSequenceTable::findByNaturalKey(autonumber);
     
              select forUpdate firstOnly numberSeqLastRec
                  where numberSeqLastRec.RecId == numberSeqTableRev.RecId;
              if (numberSeqLastRec.RecId && numberSeqLastRec.NextRec != 1)
              {
                 numberSeqLastRec.NextRec -= 1;
                 numberSeqLastRec.update();
              }
          }
          ttsCommit;
}

No comments:

Post a Comment

Copy Markup charges while posting purchase invoice using X++

 Copy Markup charges while posting purchase invoice using X++ Class: Important: Code logic is just for Reference.  New class => Duplicate...