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

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Insert new project using NextRec in number sequence in X++

(0) ShareShare
ReportReport
Posted on by 400

I am trying to insert a new record in ProjTable for our external application using proxy class. I have written a method in X++ that generates a ProjID that follows the number sequence format.

ttsbegin;
this.ProjId = NumberSeq::newGetNum(ProjParameters::numRefProjId()).num();
ttsCommit;

However, this only creates a numbersequence that starts from 0 and does not follow the number in NextRec in Numbersequencetable. How would I able to solve this?

*This post is locked for comments

I have the same question (0)
  • dianne_ramos Profile Picture
    400 on at
    RE: Insert new project using NextRec in number sequence in X++

    I have created a new method in ProjTable that will be called in a proxy for an external application that have the same codes written in ProjTable.insert(). Will that affect other modules inside AX? I have no problem with subprojectid because there is a method that I could call for creating them.

  • David Massey Profile Picture
    on at
    RE: Insert new project using NextRec in number sequence in X++

    I would not recommend overriding the insert method on ProjTable.  Set the buffer value prior to calling ProjTable.insert() within your application code.  A number of forms create project records and your code could conflict with them.  Be sure that if you are using subprojects, they it follow the ProjId naming requirements. All of the current project code uses this dependency when providing summarized data. ProjId = ParentProjId + (Current ProjId in the format specified by the parent's format str).   Code uses statements similar to select sum(amount) from table xyz where xyz.ProjId like '<ProjId>*'.

  • dianne_ramos Profile Picture
    400 on at
    RE: Insert new project using NextRec in number sequence in X++

    Hi David,

    I think it is not advisable for us to use a continuous number sequence for ProjTable. But for the meantime, I reused and modified the overridden code of the insert() method in ProjTable for the external application that I'm developing. Will that code follow when I change the number sequence setup in the future?

    Regards,

    Dianne

  • dianne_ramos Profile Picture
    400 on at
    RE: Insert new project using NextRec in number sequence in X++

    Hi Brian,

    I'll take note of that. Thanks for the info. But how can I make a number sequence automatic?

    Regards,

    Dianne

  • David Massey Profile Picture
    on at
    RE: Insert new project using NextRec in number sequence in X++

    When using "Continuous" number sequences, there is additional code which is required for the system to work correctly.  If the transaction does not consume the number, it must be released back on to the system.  This number will show up in the sequence number history as a "Free" number sequence.  The next time a number sequence is requested, the value is retrieved from this list.  

    One additional point is that the number sequences used for sub-projects is not the same as that of parent projects. These are based on the Parent Id and the format string to be used for subprojects.

  • Brian Welcker Profile Picture
    on at
    RE: Insert new project using NextRec in number sequence in X++

    "Automatic" number sequence generation (when the "Manual" checkbox is unchecked) is not the same as "Continuous". "Continuous" ensures that there are no gaps in the number sequence. For example, you would not have a P003 without a P001 and P002. Continuous requires automatic but not vice versa. The Continuous option has performance implications and should generally only be used when you have a regulatory document (e.g. invoice) where you cannot have sequence gaps.

    When you turn on manual number sequences, it is up to the user / external application to specify the ID and the system will not auto-increment the numeric values.

  • dianne_ramos Profile Picture
    400 on at
    RE: Insert new project using NextRec in number sequence in X++

    Hello Rachit,

    Thank you for the quick response. You are right that when i enable the manual checkbox in the number sequence form, it will return a blank value. But i need a sequence that will follow the projids that is already existing in my database. I think this number sequence code have a "continuous" enabled by default. By enabling manual will render continuous disabled.

    Prior to that, I have tried creating a new project inside dynamics ax and to my horror, it also resets the projId it generates for new projects to the last projId that the external application has used. I cannot create new projects since new projIds that dynamics ax generates is already existing in the database.

    I tried disabling the continuous checkbox and tried to create a new project. It returns to normal (using the nextrec in numbersequence. Updating it too upon using it). Even the external application follows the nextrec record in number sequence table. Changing it back to continuous have no effect, both applications still follows the nextrec in number sequence.

    It solved the problem but i don't know why though. Thanks for the hint!!

    Regards,

    Dianne

  • Suggested answer
    Rachit Profile Picture
    4,015 User Group Leader on at
    RE: Insert new project using NextRec in number sequence in X++

    Hi Dianne,

    Check if the number sequence code defined in projects parameters for Project ID is having a "manual" checkbox enabled in the setup group. In that case the code will return a blank value, you can refer to Classes\numberSeq\num method to understand this check.

    Hope this helps.

    Thanks,

    Rachit Garg

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…

Andrés Arias – Community Spotlight

We are honored to recognize Andrés Arias as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Syed Haris Shah Profile Picture

Syed Haris Shah 9

#2
Martin Dráb Profile Picture

Martin Dráb 2 Most Valuable Professional

#2
Community Member Profile Picture

Community Member 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans