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
Two messages above your question is a code sample that shows how to do it without using a number sequence. But please note Martin's comments about not using RecId when determining the latest record. Just pick the largest value in your id field, increment it by one and use this incremented value for your new record.
But I recommend that you use a number sequence instead.
By Number Sequence it's working but Please tell me how to do it by our own code or share the code.
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.
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.
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.
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.
Dear Mr.Faisal The link u provided is really very helpful, Thanks a lot
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.
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.
Please look at the link in my previous reply.
André Arnaud de Cal...
291,979
Super User 2025 Season 1
Martin Dráb
230,848
Most Valuable Professional
nmaenpaa
101,156