Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

Customize Number sequence error

(1) ShareShare
ReportReport
Posted on by 220
I have a customize number sequence for projects table (ProjTable). Which was already developed before my joining. We have 10 entities and in all of them the sequence number is working fine. However, the sequence number field have duplicate values in some entities ;). Duplicate values are not an issue however right now. Our functional consultant defined a new entity setup number sequence for it and start defining new projects in new entity and it start generating the following error after first successful entry.   

Cannot create a record in Hierarchies (Hierarchy). Hierarchy ID: XXXX-00002, XXX-XXX-005. The record already exists.

XXXX-00002 is sequence number and XXX-XXX-005 is project id.

I have tried to fix the problem by Manual Cleanup - > Reset, but in vain. Sometimes it gets successful but often it generates error. I have tried to remove sequence number for newly created entity but not working. 

Right now, this sequence is not useful as it has duplicate values. I have two option eighter remove this sequence number or fix the issue. 

Please give suggestions for the solution. 

Regards
 
  • nbhatti2001 Profile Picture
    220 on at
    Customize Number sequence error
    Hi Andre,
     
    Actually problem is of Hierarchy ID, that's why I mark it solved. But when I refresh that sequence and delete all projects and test it. It was not working for the particular entity. Its setting is as the other sequences, I have tries with different setting but its not working. Now I have remove the Hierarchy ID and its working fine. 
     
    However the problem was of hierarchy ID, not the sequence number.
  • André Arnaud de Calavon Profile Picture
    293,302 Super User 2025 Season 1 on at
    Customize Number sequence error
    Hi nbhatti,
     
    I'm confused. You mentioned that you still have an issue, but you also marked my reply as verified answer. If you still have an issue, can you share what exact settings you have on the number sequences. Is the Continuous option enabled for the hierarchies?
  • nbhatti2001 Profile Picture
    220 on at
    Customize Number sequence error
    Thanks Andre,
     
    Actually was facing the same issue. But still stuck with the issue. I have delete all the projects, refresh the Number Sequence which was for hierarchy ID and when add new project, it assign new hierarchy ID like XXXX-000000 and project saved. When again try to add new project then it again stuck with the XXXX-000000 and genereate the error that XXXX-000000 is already define. 
     
    Moreover I have tried with reset Number Sequence manually through batch job. 

    So please suggest how I can fix the error, for rest of entities its working fine. However I am also trying to fix.
  • Verified answer
    André Arnaud de Calavon Profile Picture
    293,302 Super User 2025 Season 1 on at
    Customize Number sequence error
    Hi nbhatti,
     
    The error is not on the projects table, but the Hierarchies. This is used for project activities. When you go to the Legal entities form, there is a tab page with number sequences. Check the set up for the reference Hierarchy ID.
  • nbhatti2001 Profile Picture
    220 on at
    Customize Number sequence error

    Hi,

    Here is the code and other detail
    class S_NumberSeqModuleProject extends NumberSeqModuleProject
    {
        public void loadModule()
        {
            NumberSeqDatatype datatype = NumberSeqDatatype::construct();
            const Integer wizardHighest = 999999;
            const Integer sortField = 20;
    
            datatype.parmDatatypeId(extendedTypeNum(S_ProjectNumber));
            datatype.parmReferenceHelp("Project number");
            datatype.parmWizardIsContinuous(false);
            datatype.parmWizardIsManual(NoYes::No);
            datatype.parmWizardIsChangeDownAllowed(NoYes::No);
            datatype.parmWizardIsChangeUpAllowed(NoYes::No);
            datatype.parmWizardHighest(wizardHighest);
            datatype.parmSortField(sortField);
            datatype.parmReferenceLabel("Project number");
    
            datatype.addParameterType(NumberSeqParameterType::DataArea, true, false);
    
            this.create(datatype);
        }
    
        public NumberSeqModule numberSeqModule()
        {
            return NumberSeqModule::Proj;
        }
    
        [SubscribesTo(classstr(NumberSeqGlobal),delegatestr(NumberSeqGlobal,buildModulesMapDelegate))]
        static void buildModulesMapSubsciber(Map numberSeqModuleNamesMap)
        {
            NumberSeqGlobal::addModuleToMap(classnum(S_NumberSeqModuleProject), numberSeqModuleNamesMap);
        }
    
    }
    class S_ProjectNumSeqJob
    {        
        /// <summary>
        /// Runs the class with the specified arguments.
        /// </summary>
        /// <param name = "_args">The specified arguments.</param>
        public static void main(Args _args)
        {
            S_NumberSeqModuleProject numberSeqMod = new S_NumberSeqModuleProject();
            numberSeqMod.loadModule();
            numberSeqMod.load();
            info("Number sequence generated");
        }
    
    }
     
    Now the current number is 19 but the in error message duplicate is 9
  • Waed Ayyad Profile Picture
    7,963 Super User 2025 Season 1 on at
    Customize Number sequence error
    Hi ,
     
    Can you share the code that you write for adding Number sequence and share setup of the number sequence.
     
    Regards,
    Waed
  • Martin Dráb Profile Picture
    232,108 Most Valuable Professional on at
    Customize Number sequence error
    Moved from D365 general forum to the Finance forum, because it seems to be about F&O and not about D365 in general. Please let me know if you disagree.

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 293,302 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 232,108 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Product updates

Dynamics 365 release plans