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 :
Finance | Project Operations, Human Resources, ...
Answered

What is the best way to check Number Sequence already setup ?

(0) ShareShare
ReportReport
Posted on by

Hi guys,

I have created a new Number Sequence for AR module and now shows correctly and nicely in AR parameters Tab Number Sequence. May I know what is the best way to check (in X code) that the number sequence is already set up ?

Usually I'm just using it with this command : 

numberSeqNewOrder = NumberSeq::newGetNum(CustParameters::numRef_My_OrderNumber());
numberSeqNewOrder.used();

SalesTable.My_OrderNumber = numberSeqNewOrder.num();

This works fine, if the setup has no done actually there is a system error saying "A number sequence has not been set up for the reference Order number in the area Accounts receivable." but I currently I need to check first before it is being retrieved. Is there an existing method for us just to check first, lets say if it is return false, I can use it to not even start my process, because actually those code above is in the middle of some process.

Thanks,

I have the same question (0)
  • Suggested answer
    SouravDam Profile Picture
    11,730 on at

    Hi VoltesDev,

    From functional perspective we can say.. there is a references section available in the number sequence which needs to set in order to validate the correct area the sequence is to be used for.

    pastedimage1673949039821v1.png

    If this is not set, you might get such issue.

    Now.. this is not mandatory to set in all cases. Sequences which needs to be set in the parameter level, for those.. this references section is mandatory.

    Regards,
    Sourav

  • VoltesDev Profile Picture
    on at

    Hi Sourav,

    Noted with thanks. However this is manual checking and I understand as you are mentioned it is from functional POV. I might need from the technical POV, as I need to write some code, but currently I have no idea what to write.

    Anyway thanks again.

  • Verified answer
    ergun sahin Profile Picture
    8,826 Moderator on at

    CustParameters::numRef_My_OrderNumber()

  • VoltesDev Profile Picture
    on at

    It works, thank you

  • VoltesDev Profile Picture
    on at

    What is actually the return of "CustParameters::numRef_My_OrderNumber()". Understood that this is a custom method but this is exactly with the same statement like the standard only with my own EDT. 

    Reason is I tried to use like this : 

    if (CustParameters::numRef_My_OrderNumber().NumberSequenceId)
    {
        .
        . 
        .
    }
    else
    {
        throw Error(strFmt("@SYS53911", "Order", "@SYS107971"));
    }

    Not sure why this is always bring me to False condition, while I debug this, the NumberSequenceId always 0 although I have setup the number sequence in AR parameter.

    For the method in that CustParameters as mentioned is written to be something like this : 

    [ExtensionOf(tableStr(CustParameters))]
    final class My_CustParameters_Extension
    {
         
        client server static NumberSequenceReference numRef_My_OrderNumber()
        {
            return NumberSeqReference::findReference(extendedTypeNum(My_OrderNumber));
        }
    
    }

    Thanks,

    thanks,

  • ergun sahin Profile Picture
    8,826 Moderator on at

    There are two point you must be looked.

    1.is there any reference to your EDT at Selected Number Seq (at parameters)

    2.Scope of Number Seq

  • Suggested answer
    VoltesDev Profile Picture
    on at

    Hi Ergun,

    Yes, the EDT already being setup, also I have filled in the parameter after it.

    Anyway, I found out the correct way to do it. Like below:

    NumberSequenceReference numberSeqRef = CustParameters::numRef_My_OrderNumber();
                if (numberSeqRef.NumberSequenceId)
                {
                }

    So it turns out I need to "hold" the numberSeqRef first in my own local variable. Cannot use the previous way of code.

    Thanks again for helping to the right path.

    Thanks

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 > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 551 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 450 Super User 2025 Season 2

#3
BillurSamdancioglu Profile Picture

BillurSamdancioglu 278 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans