Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

How to get the next number sequence of SalesQuotationProjTable

(0) ShareShare
ReportReport
Posted on by

Hello again guys,

How could I get and use the next number sequence of SalesQuotationProjTable (project quotation), without any errors when I want to utilize the number sequence via a different form?
Any help would be much appreciated.
Thanks in advance.

Codes which I have tried using:

numberSeq = NumberSeq::newGetNum(SalesParameters::numRefQuotationId());
            
HISProjQuotTbl.QuotationId = numberSeq.voucher// not working because I did it wrongly


numberSeq = NumberSeq::newGetNum(SalesParameters::numRefQuotationId());
info(numberSeq.num); //I cannot even try to print out the message as its giving an error inside the form


*This post is locked for comments

  • Verified answer
    Community Member Profile Picture
    on at
    RE: How to get the next number sequence of SalesQuotationProjTable

    After lots of trials and errors, I finally came up with a solution, which is not by using newGetNum method. (newGetNum causes error when working with continuous number sequence)

    Here is the solution:

    //put this as a global variable
    NumberSeqFormHandler numberSeqFormHandler;

    //Put this at the element level of your form NumberSeqFormHandler numberSeqFormHandler() { if (!numberSeqFormHandler) { numberSeqFormHandler = NumberSeqFormHandler::newForm( SalesParameters::numRefQuotationIdBase().NumberSequenceId, element, FormDataSource_DS, //the form's datasource fieldnum(FormDataSource, QuotationId)); } return numberSeqFormHandler; } /// <summary> /// override the form's datasource "create" method and add in the codes below /// </summary> public void create(boolean _append = false) { //add this in element.numberSeqFormHandler().formMethodDataSourceCreatePre(); //make sure the super is in the middle super(_append); //add this in element.numberSeqFormHandler().formMethodDataSourceCreate(); } /// <summary> /// override the form's datasource "delete" method and add in the codes below /// </summary> public void delete() { element.numberSeqFormHandler().formMethodDataSourceDelete(); super(); } /// <summary> /// override the form's datasource "write" method and add in the codes below /// </summary> public void write() { super(); element.numberSeqFormHandler().formMethodDataSourceWrite(); }

    I realized ievgen Miroshnikov had given the link, which provided the above solution.

    Thanks ievgen Miroshnikov for everything!

  • Community Member Profile Picture
    on at
    RE: How to get the next number sequence of SalesQuotationProjTable

    Hi ievgen Miroshnikov,

    Thanks for the reply.

    I was told not to skip quotation numbers.

    I read from several posts that mentioned continuous option effects the performance.

    If I make the number sequence non-continuous, then everything will be solved.

    However, I need to make it work like SalesCreateQuotation, where they can "grab" the next quotation id (in a normal continuous fashion-way).

    I have tried your above codes and newGetNum just does not do the trick since the system will complain about quotation id not supporting non-continuous addition.

    My table inserts the number just fine, however, I cannot force an insert into SalesQuotationTable because of the error which I have mentioned.

    I am also not blindly jumping from one implementation to another. I did it only because newGetNum does not work with a continuous number sequence (unless I am wrong)

    I, too wish that I could just set the number sequence to non-continuous and simply end this problem, but I just could not because of the given condition, which is to leave number sequence as continuous.

    I tried googling "ax get quotation id" or "ax quotation id", but I am not having much luck...

  • Mea_ Profile Picture
    60,278 on at
    RE: How to get the next number sequence of SalesQuotationProjTable

    Hi Lincoln Poh,

    Could you please stop jumping from one implementation to another and focus on one of them ?

    Lets talk about standard way of getting next number from number seq. It's easier to work with simple code, so try next job and see if it works

    HISProjQuotTbl HISProjQuotTbl; 

    ttsBegin;
    NumberSeq numberSeq = NumberSeq::newGetNum(SalesParameters::numRefQuotationId()); HISProjQuotTbl.QuotationId = numberSeq.num(); HISProjQuotTbl.insert();

    ttsCommit;


    Talking about continuous number seq, you should have them only if there are legal requirements to have continuous numbers, otherwise it's better to disable them because of performance reasons.

  • Community Member Profile Picture
    on at
    RE: How to get the next number sequence of SalesQuotationProjTable

    Thanks for the reply.

    However, like I have pointed out, I would not want to change the system's setting for transaction type. In this case, I am working with project quotation (one of the primary key, which is called "quotation id". You could find it inside "SalesQuotationProjTable" in the AOT), which definitely is considered one of the transaction. So, I would not like to remove away the continuous option away from quotation id.

    Currently, I have tried out other methods, such as:

    private void getNextNumberSequenceWithoutUpdate()
    {
    	NumberSequenceTable numberSequenceTable;
    	//Sale_423 is quotationIdBase, which is the one I am working with
    	numberSequenceTable = NumberSequenceTable::findByNaturalKey('Sale_423'); 
    	//I need to minus away 1 from NextRec, or else it would not be equivalent to the next quotation id
    	//You could find out the next quotation id by accessing project quotation, and create a new 
    	//project quotation. Then, look for the "Quotation" (this is actually the "Quotation Id" edt type)
    	info(strFmt("%1",NumberSeq::numInsertFormat(numberSequenceTable.NextRec - 1,numberSequenceTable.Format)));
    	
    	//I tried to assign it to one of the field inside my table
    	//However, the next time I run this method (getNextNumberSequenceWithoutUpdate),
    	//it will not retrieve the next quotation id from "SalesQuotationTable",
    	//even though I have inserted a new record into "SalesQuotationTable" by using the parm method,
    	//located inside the AxSalesQttable class, such as AxSalesQttable.parmQuotationId, to pass 
    	//the next quotation id.
    	HISProjQuotTbl.QuotationId = NumberSeq::numInsertFormat(numberSequenceTable.NextRec - 1, numberSequenceTable.Format);        
    }


    I hope you do understand what I was trying to say above. If it is too complicated, please do tell me. I will try to explain in more details.

    Thanks in advance.

  • Mea_ Profile Picture
    60,278 on at
    RE: How to get the next number sequence of SalesQuotationProjTable

    Go to Organization administration > Common > Number sequences > Number sequences and remove Continuous check box on General tab.

    Also it could help us to understand your issue better if you provide code that you have, so we would see that there is a transaction and so on.

  • Community Member Profile Picture
    on at
    RE: How to get the next number sequence of SalesQuotationProjTable

    Thanks for the reply again ievgen!

    I just read the URL which you had given, and, I am afraid to say that the one which I am working with is a transaction...and I should not temper with the default system settings.

    What I would like is to get the next number sequence and use it, without the error message showing up...just like I am working with a sales order's quotation id or project quotation's quotation id base.

    If I am lacking in my explanation, please do tell me. I will provide as much info as I could, as I would like to fix this issue.

    Thanks in advance, experts.

    EDIT: I just realized you mentioned two methods; The first is to make it non-continuous, the second is to allocate numbers inside of the transaction...Could you please explain more about the approach of the second method? If I were to go with the second approach, will I achieve what I need to?

    Thanks in advance.

  • Suggested answer
    Mea_ Profile Picture
    60,278 on at
    RE: How to get the next number sequence of SalesQuotationProjTable

    Let me refer you to a thread discussing similar issue community.dynamics.com/.../222202

    So either allocate numbers inside of the transaction or make it non-continuous

  • Community Member Profile Picture
    on at
    RE: How to get the next number sequence of SalesQuotationProjTable

    Thanks for the response ievgen Miroshnikov, and also thanks for trying to actively help out the community!

    I thank you on behalf of the rest of them.

    I just tried your given solution, and again, it did not work.

    In fact, I tried that out while waiting for replies to the thread.

    Edit: I have also made sure I added .used() method. I tried inserting it before and after assigning numberSeq.num() to QuotationId.

    Have a look at the picture below for the error shown in the form when executed.

    _21714C98_3.png

    It is giving errors again, just like what I tried to print using info method.

    Any idea on how to work around it?

    Thanks in advance!

  • Verified answer
    Mea_ Profile Picture
    60,278 on at
    RE: How to get the next number sequence of SalesQuotationProjTable

    Hi Lincoln Poh,

    Try

    numberSeq = NumberSeq::newGetNum(SalesParameters::numRefQuotationId());
                
    HISProjQuotTbl.QuotationId = numberSeq.num();


    if it's continuous you need to call numberSeq.used(); as well. Please refer for details https://msdn.microsoft.com/en-us/library/aa608474.aspx

  • Community Member Profile Picture
    on at
    RE: How to get the next number sequence of SalesQuotationProjTable

    Bumping to receive help.

    If this is forbidden, I will create a new thread.

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 Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Kudos to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Microsoft Dynamics AX (Archived)

#1
Mohamed Amine Mahmoudi Profile Picture

Mohamed Amine Mahmoudi 100 Super User 2025 Season 1

#2
Community Member Profile Picture

Community Member 48

#3
shanawaz davood basha Profile Picture

shanawaz davood basha 6

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans