Thursday, November 03, 2005

Automatic Number Sequence Attach Code

I find this very great in case if any one wants to attach a number sequence manually created to a particular column in Axapta. We have to write the code in create, write, delete override methods in the table we wanted to have a number sequence to be attached. Here the table is name is Test_Table and the column name for which number sequence to be attached is Test_Num

public void create(boolean _append = false)
{
super(_append);
numberSeq = NumberSeq::newGetNumFromCode("Test_001", true,true);
if (numberSeq)
{
Test_Table.Test_Num = numberSeq.num();
numAllocated = Test_Table.Test_Num;
}
}

public void write()
{
;
ttsbegin;
if (numberSeq && Test_Table.Test_Num == numAllocated)
numberSeq.used();
else
{
if (numberSeq)
numberSeq.abort();
}
super();
ttscommit;
}

public void delete()
{
ttsbegin;
if (!Test_Table.RecId && numberSeq)
numberSeq.abort();
super();
ttscommit;
}


Comments: Post a Comment

Links to this post:

Create a Link



<< Home

This page is powered by Blogger. Isn't yours?