generate numbers for field automatically

please tell how to create a number automatically for a field

let suppose id is there when i create new record it automatically takes 1 then 2 than 3 and soon on creating new records

RG,

Create Number sequence for that field…u will get automatic sequence on each new record.

Trish!

how can i create that Number sequence fo hat field

could you pls explain the steps?

my table->sample

my field name-> Subject should i want to change in properties

Manimaranvasan,

Number sequence is generated by setup, parameters and small code. What version of AX you are using i ll send the procedure as it is a bit long procedure.

Trish!

im using ax2009 version

are you sending that in usergrop or through mail

manimaran.kasi@levergent.com

i am using ax2009

but can you please elaborate as i have gone through and created new no sequence through setup as well as written the code but cant able to get the result

mail me at miraclerah@gmail.com

Hi,

To let any field to be generated sequentially you must do the following:

Suggest i have a table named Table and a field named ID, the extended data type for Id is EDT
and i have a Form named Form

  1. For example if the Form is located in Inventory managment Module you should find the class named NumberSeqReference_Inventory, then go to LoadModule method in that class and write the following at last:

numRef.dataTypeId = typeId2ExtendedTypeId(typeid(EDT)); //Extended datatype related to Id.
numRef.referenceHelp = literalStr(“HelpText”); // Your help text to be viewed in Parameters later.
numRef.wizardContinuous = true;
numRef.wizardManual = NoYes::No;
numRef.wizardAllowChangeDown = NoYes::No;
numRef.wizardAllowChangeUp = NoYes::No;
numRef.wizardHighest = 99999999;
numRef.sortField = 1;

this.create(numRef);

2)Then go to Table node and find InventParameters, go to methods node then add a new method and write the following:

server static NumberSequenceReference numRefID()
{
return NumberSeqReference::findReference(typeId2ExtendedTypeId(typeid(EDT))); //Extended datatype
}

3)Then go to Inventroy managment content pane → Setup → Parameters → Number Sequences Tab
now here you will see the Extended Data type EDT and an empty Sequence number code, right click the empty lookup and click Go to the main table Form.
Add a new number sequence code in the opened form and save it [for example]:
Number sequence code: IDNumberSeq
Name: NEWNumberSeq
Smallest: 1
Largest: 99999999
Next: 1
Format: ID_######## // Format whatever you want to give
InUse: Checked

Return to previous Form “Parameters” and choose IDNumberSeq that we have just created it from Number sequence code lookup to EDT Reference

3)Last thing to do is Go to Form → Datasources node → Table → Methods, and override method (create) and write the following:

public void create(boolean _append = false)
{
;
super(_append);

Table.ID= NumberSeq::newGetNum(InventParameters::numRefID(),true).num(); //numRefID() is a method created in step 2)
}

//End

Finally go to the form and create a new record and you will see your number is generated automatically and sequentially.

Note: go to Table and set Id field to( AllowEdit:No AllowEditOnCreate:No ) if you dont want anyone to edit the generated number.

Trish!

thanks trish

thanks Thrish

i got the best explanation till now