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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Number sequence on the form error. Please help

(0) ShareShare
ReportReport
Posted on by

Hi everyone,

I've got a problem using the number sequence on the form, can't get my head around what causes it. Maybe someone here can help

I've created a new Table & a Form for my new business entity. Table has got just 3 fields, only one - ID is mandatory and I've created a Number sequence for it. Number sequence is maintained on the form via numberSeqFormHandler

When I create a new record on the form new number gets assigned to the current record. i.e everything is ok . BUT... If I create another record by pressing Ctrl-N straight after(without explicitly saving the previous record) I get a error "A new number cannot be assigned because XXX has not been saved or deleted." It looks like for some reason write() of the DS where is not being called if I press Ctrl+N twice thus

 element.numberSeqFormHandler().formMethodDataSourceWrite();


is not called causing the error upon the new number seq number creation.  Is it a std behaviour?

Thank you very much for your help!

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Mea_ Profile Picture
    60,284 on at

    Hi Zetta,

    In create() method of the datasource you should have

    public void create(boolean _append = false)
    {
        element.numberSeqFormHandler().formMethodDataSourceCreatePre();
    
        super(_append);
    
        element.numberSeqFormHandler().formMethodDataSourceCreate();
    }


    where element.numberSeqFormHandler().formMethodDataSourceCreatePre(); will save previous record first.

  • Community Member Profile Picture
    on at

    Hi Ievgen

    I have that code and essentially it's formMethodDataSourceCreatePre() that throws my error as lastNumber exists till the record is saved

    void formMethodDataSourceCreatePre()
    {
        ;
        validateWriteCalled = false;
        validateWriteFailed = false;
    
        if (lastNumber)
        {
            throw(error(strFmt("@SYS121794", lastNumber)));
        }
    }


     

    void formMethodDataSourceCreatePre()

    {

    ;

    validateWriteCalled = false;

    validateWriteFailed = false;

    if (lastNumber)

    {

    throw(error(strFmt("@SYS121794", lastNumber)));

    }

    }

  • Verified answer
    Mea_ Profile Picture
    60,284 on at

    It's a well-known issue caused by confusing order of method calls when you click ctrl + n without saving previous record. If you check LedgerJournalTransAsset form, create method of LedgerJournalTrans datasource you will see next code with comment:

    // Fix for bug 283050. leaveRecord is not called if Ctrl-N is hit on unsaved record.
    // We explictly call leaveRecord to account for the scenario, before the X++ code
    // throws an errror in the line below journalFormTrans.dataSourceCreatePre().
    this.leaveRecord();

    So literally you need to call leaveRecord to force write of previous record. 

  • Community Member Profile Picture
    on at

    Thank you so much!

    Can't believe that such a fundamental core issue was not fixed by MS yet!! Frustrating ....

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans