Thursday, January 21, 2016

Number Sequence Creation through Code X++

//Number Sequence Creation through Code X++

static void Fcc_NumberSeqTest(Args _args)
{
     NumberSequenceTable                numberSeqTable;
     NumberSequenceScope                numberSeqScope;
     container                          segments;
     str                                annotatedFormat, format;
     NumberSequence                     sequence;
     Args                               args = new Args();
     ;
     select  numberSeqScope
           where numberSeqScope.DataArea == 'dataAreaId';
     segments += [[0, 'CVT']];
     segments += [[-1,'-']];
     segments += [[-2,'######']];
     annotatedFormat  = NumberSeq::createAnnotatedFormatFromSegments(segments);
     format           = NumberSeq::createAnnotatedFormatFromSegments(segments, false);
     numberSeqTable.clear();
     numberSeqTable.NumberSequence      = 'CVTst';
     numberSeqTable.Txt                 = 'Test Seq';
     numberSeqTable.AnnotatedFormat     = annotatedFormat;
     numberSeqTable.NumberSequenceScope = numberSeqScope.RecId;
     numberSeqTable.Format              = format;
     numberSeqTable.Highest             = 999999;
     numberSeqTable.Lowest              = 1;
     numberSeqTable.NextRec             = 1;
     numberSeqTable.insert();  
   
     args.record(NumberSequenceTable::find(numberSeqTable.RecId));
     new MenuFunction(MenuItemDisplayStr(NumberSequenceDetails),MenuItemType::Display).run(args);
}

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