Notifications
Announcements
In my project i am using the field called AcademicID, which should auto increment the value(integer) for each input given. pls hep me thanks in advance
*This post is locked for comments
AX typically uses the Number Sequence Framework for these things, although you can implement an auto-increment field by your own code, if you want.
Dear Mr.Martin, Thanks for your response, can u pls share the code or explain about how to use Number Sequence Framework?, because am new to IT and Ax.
Please look at the link in my previous reply.
Hi Anand, Please have a look on this link which explains step by step how to use number sequence in AX 2012.
http://daxture.blogspot.co.nz/2014/09/number-sequence-framework-step-by-step.html
Mark it as an answer if it helps you.
as you field AcademicID is a integer field so
I suggest you should override initvalue() method on the table to write logic to increment the value.
simple logic would be
count the number of record in table and
assign value to AcademicID field by incrementing the total value by 1
Please verify if this helps you.
Dear Mr.Faisal The link u provided is really very helpful, Thanks a lot
Doing it in initValue() would likely lead to duplicate values (or DuplicateKeyException if there is a unique index), because before the record gets written to dataabase, initValue() may be called for other records and they would all get the same value.
Hi ,
I need suggestion,
working on Ax 2009,
I have a field say F1 and I am using it in a for loop, now my requirement is :
till the loop runs the F1 value should Increment by 1, say field value F1= A100, if loop run for 5 time, the the field value should be increment like this A101,A102..A105.
It's Easy To Create in Number Sequence in DataSource.
Create DataSource Create Method.
public void create(boolean _append = false) { int max1; A_Marks _Marks; str 60 Value; str 60 _newCode; ; //breakpoint; super(_append); select firstOnly ID from _Marks order by RecId desc;// query to find last number if(!_Marks.ID)// When table is blank { _newCode='MT_'+ strRFix(int2str(1),3, "0");//Assigne value to table field DSMarks.ID = _newCode;//Assigne value to table field } else { max1=str2int(subStr(_Marks.ID,4,3))+1;// When table is not blank, add 1 DSMarks.ID ='MT_'+ strRFix(int2str(max1),3, "0");//Assigne value to table field }// if Close }
Might be Help this Code.
Thanks.
It has the same problem as doing it in initValue(). Also the sorting by RecId is wrong - the record with highest RecId doesn't have to have the highest ID.
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.
As AI tools become more common, we’re introducing a Responsible AI Use…
We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
Martin Dráb 2 Most Valuable Professional
Nakul 2
user5555 2