how to create a new module in ax 2009 with new number sequence

hi,

I want to create a new module name as Maintenance and foe this want to create new number sequence …

two forms namely … maintenance and parameters …

in maintenance form i create table name as maintenance with following fields like (maintenance Id , customer name , from date , to date )

and in parameters form i using for create new number sequence …

1.) how to create new module in dynamics ax 2009.

2.) how to generate new number sequence for newly creating module …

3.) if i want to create new table for creating number sequence r not ?

Hi Kavin,

You also posted the same question on the Dynamics Community. Here is the same answer:

You can create a new module by e.g. a new menu and/or configuration key. The new menu can contain sections for common tasks, inquiries, reports, setup etc.

To create a new module for the number sequence you have to take a look at the classes NumberSeqReference and e.g. NumberSeqReference_Bank. There must be a similar class for your new module. The inherited class needs to be referenced in some methods of the NumberSeqReference class.

Not that the parameters table should have a method to find the number sequence. You can take the BankParameters table as example.

You don’t have to create a new table for creating the number sequences. You only need a new Maintenance table, a parameters table and a new Extended data type for the MaintenanceId.

Hi andre thanks for your information …

likewise i trying for to create a new module and successfully i created … In number sequence i getting error

Unfortunately my USB crystal ball is broken, therefore I don’t know what you’ve done and what error you’re getting. Maybe if you actual explain your problem, it will be possible to give you some advice.

Hi Martin …

here i create a new module name as Maintanence … and i create a table name like maintanence table in that i add five fields namely ( Maintanence Id , customer name , from date , to date and key ) … after this i create a form for maintanence ( maintanence id field i create for number seq)…

another form created for new module maintanence ( creating new number sequence) in this form i use four methods

public class Parameters extends ObjectRun

{

NumberSeqReference numberSeqReferenceParameters;

boolean runExecuteDirect;

TmpIdRef tmpIdRef;

Dimension listViewDimension;

fieldId tmpFieldId;

SalesPurchSummarySumByCtrl sumByCtrl;

}

//////////////////

public void init()

{

this.numberSeqPreInit();

super();

// PurchParameters::find();

// PurchRFQParameters::find();

Maintanence::find();

PurchReqParameters::find();

// this.maintanenceInit();

AxdDocumentParameters::find();

this.numberSeqPostInit();

InventDimSetupGrid::loadSetup();

// this.fillView();

// sumByCtrl = SalesPurchSummarySumByCtrl::newSumByControl(summaryupdate_SummaryUpdateBy);

// sumByCtrl.remove(AccountOrder::Journal);

// sumByCtrl.build();

}

////////////////////////////

void numberSeqPreInit()
{
runExecuteDirect = false;

numberSeqReferenceParameters = Maintanence::numberSeqReference();
numberSeqReferenceParameters.load();

tmpIdRef.setTmpData(NumberSequenceReference::configurationKeyTableMulti(
[PurchParameters::numberSeqModule(),
Maintanence::numberSeqModule()]));
}
////////////////////////

void numberSeqPostInit()
{
numberSequenceReference_ds.object(fieldnum(NumberSequenceReference, AllowSameAs)).visible( numberSeqReferenceParameters.sameAsActive());

}
/////////////////////////////
and added data source for number sequence reference table in this form and design …
after this i create a class for new number sequence for maintanence module …
1.) class declaration 2.) loadmodule 3.)numberSeqmodule . and i create coding in class number sequence reference ( construct and loadmodule list)

after this i getting complete design as how account payable and other module having like

after this i creating a number seq for maintanence id in basic → setup → number sequence and generated new one for my field … i completed all process for creating a number seq to my table field … while i running my form maintanence it creating a record in my form but for next record i created means error message coming for record already exists … ( 1st record coming with number seq for next record continues number coming but not able to save it …

can you help me to solve this error

Obviously your code assigning the value from number sequence doesn’t work correctly. That’s all what I can say, because you didn’t mention anything about such code.

I would even suspect you don’t have any and your field is always empty, but it would mean that your statement (“1st record coming with number seq”) is not true.

Hi Martin … here i attach two images please see that image i getting number sequence and save it for first record but not able to save the second record in form … i getting error info log

But MaintenanceId has unique values, doesn’t it? (Although I’m surprised that the values don’t seem to come from the same number sequence.) If MaintenanceId is all right, you’re trying to fix something that already works instead of the broken thing.

First of all, find where the error is thrown from. You may have a bug in code trying to save the same record twice.

If it’s thrown by AX kernel, review unique indexes on the Maintenance table. Maybe the collision is caused by a different field than MaintenanceId.

I miss to assign index field in table … and update method missing in form for creating it …

i solve the error and now new number seq creating correctly for maintanence module … thanks for your inputs for solve the errors

Please mark the helpful reply (replies) as the verified solution.

Hai every one … here i posting exact answer for creating a new module in ax dynamics 2009 …

for creating a new module . open AOT → MENU → and create a new menu (Maintanence) and select properties in that select SET COMPANY - YES and choose image for (MAINTANENCE) need set NORMAL RESOURCE in properties for assign with value and select file from your PC …

after completing this . open (MAIN MENU) in AOT → MENU … and drag the MAINTANENCE to MAIN MENU for display in CONTENT PANE …

after completing all above steps start do this steps like this make sure in that MAINTANENCE module if need any SUB-MENU means adding in MAINTANENCE … right click on MAINTANENCE–> NEW → SUB-MENU for creating in that …

once creating a SUB-MENU go to proceed for creating a new number sequence for MAINTANENCE …

here i use two table and two forms for completing create a new module and number sequence …

table names

1.) MAINTANENCE in MAINTANENCE i use one field name KEY in that field properties make sure do this steps all (AllowEditOnCreate – no, Visible – no , AllowEdit – no, and mention EDT)

table methods for MAINTANENCE /////////////////////////////

void update()

{

super();

flush Maintanence;

}


static Maintanence find(boolean _forupdate = false)
{
Maintanence parameter;

parameter.selectForUpdate(_forupdate);

select firstonly parameter
index Key
where parameter.Key == 0;

if (!parameter && !parameter.isTmp())
{
Company::createParameter(parameter);
NumberSeqReference::construct(Maintanence::numberSeqModule()).load();
}

return parameter;
}

static client server NumberSeqModule numberSeqModule()
{
return NumberSeqReference_Maintanence::numberSeqModule();
}

static client server NumberSeqReference numberSeqReference()
{
return NumberSeqReference::construct(Maintanence::numberSeqModule());
}

2.)MAINTANENCE TABLE …

create this for number sequence … field name MAINTANENCE Id and mention in properties EDT for this field

and create this method in table methods for number sequence

static client server NumberSequenceReference numRefMaintanenceId()

{

return NumberSeqReference::findReference(typeId2ExtendedTypeId(typeid(MaintanenceId)));

}

continues …

here i create two forms names are ( 1.parameters ) in this form i use toe data source ( MAINTANENCE & NUMBER SEQUENCE REFERENCE) and write coding in methods are

public class Parameters extends ObjectRun

{

NumberSeqReference numberSeqReference;

FormCheckBoxControl ctrlAllowSameAs;

FormStringControl ctrlLabelSameAs;

boolean runExecuteDirect;

TmpIdRef tmpIdRef;

}


public void init()
{
this.numberSeqPreInit();

super();

Maintanence::find();

this.numberSeqPostInit();

}

void numberSeqPreInit()
{
runExecuteDirect = false;

numberSeqReference = Maintanence::numberSeqReference();
numberSeqReference.load();
tmpIdRef.setTmpData(NumberSequenceReference::configurationKeyTable(Maintanence::numberSeqModule()));
}

void numberSeqPostInit()
{
NumberSeqReference numberSeqReferenceProd;

;
numberSeqReferenceProd = Maintanence::numberSeqReference();
NumberSequenceReference_ds.object(fieldnum(NumberSequenceReference, AllowSameAs)).visible(
numberSeqReference.sameAsActive()|| numberSeqReferenceProd.sameAsActive());

}

void executeQuery()
{
if (runExecuteDirect)
{
super();
}
else
{
runExecuteDirect = true;
this.queryRun(NumberSeqReference::buildQueryRun(NumberSequenceReference, tmpIdRef, Maintanence::numberSeqModule()));
NumberSequenceReference_ds.research();
}
}

void removeFilter()
{
runExecuteDirect = false;
NumberSequenceReference_ds.executeQuery();
}

after completing this all steps run the form means it open new

continues … 2 nd form name MAINTANENCE add following code in this methods

public class FormRun extends ObjectRun

{

NumberSeqFormHandler numberSeqFormHandler;

}


NumberSeqFormHandler numberSeqFormHandler()

{

if (!numberSeqFormHandler)

{

numberSeqFormHandler = NumberSeqFormHandler::newForm(MaintanenceTable::numRefMaintanenceId().NumberSequence, element, MaintanenceTable.dataSource(),fieldnum(MaintanenceTable,MaintanenceId));

}

return numberSeqFormHandler;

}


public void create(boolean _append = false)

{

element.numberSeqFormHandler().formMethodDataSourceCreatePre();

super(_append);

element.numberSeqFormHandler().formMethodDataSourceCreate();

}


public void delete()

{

element.numberSeqFormHandler().formMethodDataSourceDelete();

super();

}


public void write()

{

super();

element.numberSeqFormHandler().formMethodDataSourceWrite();

}


after completing this two forms … adding it into menu item for display in content pane for module name ------ maintanence ----> sub menu name ------ setup—> menu item name ------- parameters …

this all steps want to create newly for create a new module with number sequence … and in class want to create new class for newly create module (MAINTANENCE )

class NumberSeqReference_Maintanence extends NumberSeqReference

{

}


protected void loadModule()

{

NumberSequenceReference numRef;

;

/* Setup Customer numbers */

numRef.dataTypeId = typeId2ExtendedTypeId(typeid(MaintanenceId));

// numRef.configurationKeyId = configurationKeyNum(MaintanenceBasic);

numRef.referenceHelp = literalStr("@SAI394");

numRef.wizardContinuous = true;

numRef.wizardManual = NoYes::No;

numRef.wizardAllowChangeDown = NoYes::No;

numRef.wizardAllowChangeUp = NoYes::No;

numRef.wizardHighest = 999999;

numRef.sortField = 1;

this.create(numRef);

numRef.dataTypeId = typeId2ExtendedTypeId(typeid(MaintanenceId));

numRef.referenceHelp = “Unique key for the Complaint Report”;

numRef.wizardContinuous = true;

numRef.wizardManual = NoYes::No;

numRef.wizardAllowChangeDown = NoYes::No;

numRef.wizardAllowChangeUp = NoYes::No;

numRef.wizardHighest = 999999;

this.create(numRef);

}


public static client server NumberSeqModule numberSeqModule()

{

return NumberSeqModule::Main;

}


after this want to add two important steps in class ------> number seq reference ------------> construct & loadmodulelist . i mention in below picture

thats it … a new module and number seq creating successfully … thanks for MARTIN & ANDRE for your information was helpful to resolve my problems and complete for creating a new module