Skip to main content

Notifications

Announcements

No record found.

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);

    }


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

    Thanks it resolved my issue.

  • Verified answer
    Martin Dráb Profile Picture
    Martin Dráb 230,476 Most Valuable Professional on at
    RE: Number sequence in X++

    Consider using my previous suggestion, i.e. deleting the record in NumberSequenceDatatype and generating it again.

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

    Ok did the following steps.

    1. Went to OA deleted my NS.

    2. Ran my numseqload class as start up object code of which is shared below, (basically it calls my numseqmodule class (code shared in previous post)) 

    class Mynumseqload
    {
        public static void main(Args _args)
        {
           Mynumseqmodule  numSeq = new Mynumseqmodule  ();
            numSeq.load();
            info ("Numseq load successfuly");
        }
    
    }


    3. Got message"Numseq load successful".

    4. Ran NS Wizard, saw my NS in the Wizard screen.

    5.Saw my NS in list of NS , clicked edit on NS form & clicked on add under segment section.

    6. Still cannot enter any value for added row , pls refer pic.

    NSeditissue.PNG

    7. Ran your 2 lines of code and still see same values for debugging i.e. scopeMap 0 & scope {<>}

    I am sure I am doing something wrong, pls point & suggest fix.

  • Suggested answer
    Martin Dráb Profile Picture
    Martin Dráb 230,476 Most Valuable Professional on at
    RE: Number sequence in X++

    Okay, I was right - you don't have any scope there, because the record was created for your old code (where you didn't define scope parameters). Delete the record and run the code again.

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

    Embedded your code  in a run class and got these results during debugging.

    scopeMap = 0;

    scope = {<>}

  • Martin Dráb Profile Picture
    Martin Dráb 230,476 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);
  • Mav Profile Picture
    Mav 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.

  • André Arnaud de Calavon Profile Picture
    André Arnaud de Cal... 291,784 Super User 2024 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
    Mav 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));
        }
    
    }


  • Martin Dráb Profile Picture
    Martin Dráb 230,476 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.

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

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,784 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,476 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans