web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Dynamics 365 Community / Forums / Finance forum / Number sequence in X++
Finance forum

Number sequence in X++

(0) ShareShare
ReportReport
Posted on by

Hi

I have successfully created NS using X++ code.

Only issue i m facing is that I cannot edit the segment of my NS so as to have format comprising of Company, Contant & Alphanumeric , instead my NS is only Alphanumeric & wont allow to add Company or constant in its segment. Please find my code for load module method shared below & kindly suggest a fix.

Also please note that whenever I chosee ParamWizardIsCOntinious as true , i get error & cant generate my NS.  So wanted to check if there is any way to create continuous NS in X++ or by default we cant create Continuous NS in X++.

protected void loadModule()
    {
        NumberSeqDatatype datatype = NumberSeqDatatype::construct();

        datatype.parmDatatypeId(extendedTypeNum(Myenum));
        datatype.parmReferenceHelp(literalstr("my NS desc"));
        datatype.parmReferenceLabel(literalstr("my NS"));
        datatype.parmWizardIsManual(NoYes::No);
        datatype.parmWizardIsContinuous(false);
        datatype.parmWizardIsChangeDownAllowed(NoYes::No);
        datatype.parmWizardIsChangeUpAllowed(NoYes::No);
        datatype.parmWizardHighest(999999);
        datatype.parmSortField(1);

        this.create(datatype);

    }


I have the same question (0)
  • Sohaib Cheema Profile Picture
    49,434 User Group Leader on at
    RE: Number sequence in X++

    How about adding some line of code, just before this.create(datatype);

    datatype.addParameterType(NumberSeqParameterType::DataArea, true, false);
  • Mav Profile Picture
    on at
    RE: Number sequence in X++

    Added the above line of code, yet it wont let me edit the segments.

    Pls refer pic below I can add new rows under segment but it wont let me enter Company or Constant or for that matter anything in Segment column.

    ns.png

  • Martin Dráb Profile Picture
    237,660 Most Valuable Professional on at
    RE: Number sequence in X++

    Have you run the code? Have you switched the scope in the number sequence form?

  • Mav Profile Picture
    on at
    RE: Number sequence in X++

    Did ran the code & hence i can see my NS in my newly created module.

    NS scope is shared & cant be edited.

  • Blue Wang Profile Picture
    on at
    RE: Number sequence in X++

    Hi Mav,

    You need to add a method to consume your newly created Number Sequence. That will return a number sequence reference object for that specific data type.
    we are going to create a new extension class of CustParameters table.

    [ExtensionOf(tableStr(CustParameters))]
    final class CustParameters_Extension
    {
       client server static NumberSequenceReference numRef()
       {
    return NumberSeqReference::findReference(extendedTypeNum(Myenum));
    } }

    There is an example: https://daxbeginners.wordpress.com/2018/01/07/d365-ax7-how-to-create-number-sequence/

    You can also refer to Microsoft Docs: https://docs.microsoft.com/en-us/dynamicsax-2012/developer/number-sequence-framework

  • Martin Dráb Profile Picture
    237,660 Most Valuable Professional on at
    RE: Number sequence in X++

    You say that the fact that you see the number sequence proves that you've run your modified code, but it's not true. You saw the number sequence even before adding addParameterType(), therefore it proves that you ran the old code, but not necessarily the new code.

    You may also need to delete NS elements that you created by your old code.

  • Mav Profile Picture
    on at
    RE: Number sequence in X++
    Thanks all for their replies.

    Hi @Bluewang
    I am already doing that pls check code below.

    static NumberSequenceReference numrefmyNS() { return NumberSeqReference::findReference(extendedTypeNum(MYEDT)); }

    Hi @Martin 

    I have deleted my NS from Orgadmin.

    Recreated the NS with below code & unfortunately still cannot edit parameters so that I can add constant & company to my newly created NS.

    Sharing full code below, please note I can see new module , My NS being populated in NS form, however still cant add constant & company to my newly created NS.

    class Mynumseqmodule extends NumberSeqApplicationModule
    {
       protected void loadModule()
        {
            NumberSeqDatatype datatype = NumberSeqDatatype::construct();
            /* Setup Myns number sequences */
    
            datatype.parmDatatypeId(extendedTypeNum(MyEDITstring));
            datatype.parmReferenceHelp(literalstr("MY NS"));
            datatype.parmReferenceLabel(literalstr("MY NS HELP"));
            datatype.parmWizardIsManual(NoYes::No);
            datatype.parmWizardIsContinuous(false);
            datatype.parmWizardIsChangeDownAllowed(NoYes::No);
            datatype.parmWizardIsChangeUpAllowed(NoYes::No);
            datatype.addParameterType(NumberSeqParameterType::DataArea, true, false);
            datatype.parmWizardHighest(999999);
            datatype.parmSortField(1);
    
            this.create(datatype);
    
        }
    
        [SubscribesTo(classStr(NumberSeqGlobal), delegateStr(NumberSeqGlobal, buildModulesMapDelegate))]
        static void buildModulesMapSubscriber(Map numberSeqModuleNamesMap)
        {
            NumberSeqGlobal::addModuleToMap(classNum(Mynumseqmodule ), numberSeqModuleNamesMap);
        }
    
        public NumberSeqModule numberSeqModule()
        {
            return NumberSeqModule::Mynseqmodule;
        }
    
        static NumberSequenceReference numrefMYNS()
        {
            return NumberSeqReference::findReference(extendedTypeNum(MyEDITstring));
        }
    
    }


  • André Arnaud de Calavon Profile Picture
    300,714 Super User 2025 Season 2 on at
    RE: Number sequence in X++

    Hi Mav,

    Probably a stupid question from me... Did you actually click the Edit button (top left) on the form? Can you change other fields on this number sequence record?

  • Mav Profile Picture
    on at
    RE: Number sequence in X++

    @Andre

    Thanks for your note, i believe that there are no stupid questions when asked in direction of resolving the problem :-).

    Yes I am clicking on edit & shared below are details.

    Properties I can't edit

    Scope

    Segments

    Properties i can edit

    General

    Performance.

  • Martin Dráb Profile Picture
    237,660 Most Valuable Professional on at
    RE: Number sequence in X++

    I still suspect that you have the old scope in NumberSequenceDatatype table. Can you check it, please?

    You can use this piece of code:

    int scopeMap = NumberSequenceDatatype::findByDatatypeId(extendedTypeNum(MyEDITstring)).ScopeType;
    List scope = NumberSeqScope::getParameterTypesForScopeType(scopeMap);

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard > Finance

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans