AutoNumber in Axapta

Hi, anyone could tell me how to use autonumber in Axapta? Any help would be appreciated ! Thanks

Do you mean how to tell Axapta in which way to automatically generate i.e. a customer numbers when setting up a new customer? You can set this up in Basic/Setup/Number sequences/Number sequence

Thank you Nils I want to create a primary key field which value is i.e. pay_001 , pay_002 , pay_003. I want this to be generated automatically with Axapta. How can I accomplish this with number sequence ? Regards,

You can give auto increment property directly on SQL Server

I don’t want to directly make any change on SQL Server. I want this to be accomplished using MorphX only. Any help?

Hi Agusacil in the mask field on the Advanced tab on the numberseries in question, put pay_###. This will give you pay_001, pay_002 and so on.

I did. Then how to use it on my field? What property should be set on the field properties so that this sequence number take into effect?

Hallo Agus, i’ve got this code from [development-AXAPTA] milist … i’ve tried it and it’s work … hope it’s can help … example u have a table and a form name “AGUS” and the field you want to assign with number sequences is named “Field1” you should do the step below : -create a new record on mainmenu | basic | setup | number sequences | number sequences assume you choose “MyNumSeq” as Id. - modify method classDeclaration on form AGUS, add a code-line like NumberSeqFormHandler seq; - add a new method on form AGUS with code like NumberSeqFormHandler numberSeqFormHandler() { if (!seq) { seq = numberSeqFormHandler::newForm(“MyNumSeq”, element, AGUS_DS, fieldNum(AGUS, Field1) ); } return seq; } - override the datasource method create() like public void create(boolean _append = false) { super(_append); element.numberSeqFormHandler().formMethodDataSourceCreate(); } - override the datsource method delete() like void delete() { ttsbegin; element.numberSeqFormHandler().formMethodDataSourceDelete(); super(); ttscommit; } - override the datasource method write() like void write() { ; ttsbegin; element.numberSeqFormHandler().formMethodDataSourceWrite(); super(); ttscommit; } - override the datasource method validateWrite() like public boolean validateWrite() { boolean ret; ret = super(); if (ret && !element.numberSeqFormHandler ().formMethodDataSourceValidateWrite()) { ret = false; } return ret; } Best Regards, Danang Ismu

Thanks a lot, Danang Ismu ! Your code really works.

Hey i have tried for the same and same code still its not working please let me inform if any suggetion. I m new to Axapta. so please let me inform from basic if possible. Thank you.

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

Suggest i have a table named NoobsTable and a field named NoobId, the extended data type for NoobId is NoobEDT
and i have a Form named NoobsForm

  1. For example if the NoobsForm 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(NoobEDT)); //Extended datatype related to NoobId.
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 numRefNoobId()
{
return NumberSeqReference::findReference(typeId2ExtendedTypeId(typeid(NoobEDT))); //Extended datatype
}

3)Then go to Inventroy managment content pane → Setup → Parameters → Number Sequences Tab
now here you will see the Extended Data type NoobEDT 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: NoobNumberSeq
Name: NoobNumberSeq
Smallest: 1
Largest: 99999999
Next: 1
Format: Noob_########
InUse: Checked

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

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

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

NoobsTable.NoobId = NumberSeq::newGetNum(InventParameters::numRefNoobId(),true).num(); //numRefNoobId() 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 NoobsTable and set NoobId field to( AllowEdit:No AllowEditOnCreate:No ) if you dont want anyone to edit the generated number.

Atrees