Many times we have to generate and assign sequence number in X++. And usually we find attached sequence number form Parameter tables. We can get customer through following X++ code
NumberSeq _sequence;
ttsBegin;
_sequence = NumberSeq::newGetNum( CustParameters::numRefCustAccount());
info((_sequence.num()));
info(_sequence.Num());
info((_sequence.num()));
ttsCommit;
But sometimes these reference methods did not available in these Parameters table. For these fields you can get sequence number with reference to extended data type. For example if you have to find next value for CustInvoiceId of Free text Invoice of customer you have check the extended data type of field. And then get the next number with reference to Extended Data Type
NumberSeq _sequence;
ttsBegin;
_sequence = NumberSeq::newGetNum( NumberSeqReference::findReference(extendedTypeNum(CustInvoiceId)));
info((_sequence.num()));
ttsCommit;