Creating number seq:
Hello Friends,
Today I want to describe about how
to create number sequence in AX2012
It is same as like as we know in
Ax2009 but small steps is added in AX2012.don't worry just follow the below
steps simply we will get number sequence in AX2012.
We will Take a EDT name as
"CarId" and create in number sequence. For that first we should
select a module for new number sequence for example project module.
steps:
1. Create an edt : CarId .
AOT
>> Extended Data Types >> New >> Properties >>
Name >> Car Id.
2.
Write a code on lode module() on NumberSeqModuleProject
{
datatype.parmDatatypeId(extendedTypeNum(Car Id));
datatype.parmReferenceHelp(literalStr("@SYS334483"));
datatype.parmWizardIsManual(NoYes::No);
datatype.parmWizardIsChangeDownAllowed(NoYes::No);
datatype.parmWizardIsChangeUpAllowed(NoYes::No);
datatype.parmWizardHighest(999999);
datatype.parmSortField(20);
datatype.addParameterType(NumberSeqParameterType::DataArea, true, false);
this.create(datatype);
}
3.Write a method on Projparameters Table
client server
static NumberSequenceReference
numRefcarId()
{
return
NumberSeqReference::findReference(extendedTypeNum(car
Id));
}
4.Write a job and run that
static void
Carid(Args _args)
{
NumberSeqModuleProject
NumberSeqModuleProject = new
NumberSeqModuleProject();
;
NumberSeqModuleProject.load();
}
5. Then run the wizard
Organization
Administration >> CommonForms >>
Numbersequences>>Numbersequences>> Generate >> run the
wizard.
6.Now we have to check the number sequence is correctly
working for that write a job:
static void
number(Args _args)
{
NumberSeq numberSeq;
CarId num;
;
numberSeq = NumberSeq::newGetNum(ProjParameters::numRefcarId());
num = numberSeq.num();
info(num);
}
Run
the above job.We will find the generated Number
sequence.
.
7. Now we want that Number Sequence in form level(Car Table):
Declare the number sequence On Form Declaration:
public class
FormRun extends ObjectRun
{
NumberSeqFormHandler numberSeqFormHandler;
}
8. Write the NumberSeqFormHandler() in form methods node.
NumberSeqFormHandler
numberSeqFormHandler()
{
if (!numberSeqFormHandler)
{
numberSeqFormHandler =
NumberSeqFormHandler::newForm(ProjParameters::numRefcarId ().NumberSequenceId,
element,
CarTable_DS,
fieldNum(CarTable, Car Id)
);
}
return numberSeqFormHandler;
}
9. Write the close() on the form methods node.
void close()
{
if (numberSeqFormHandler)
{
numberSeqFormHandler.formMethodClose();
}
super();
}
10. Then final add the below methods on data source methods
node
Create()
void create(boolean
append = false,
boolean
extern = false) // If created
externally
{
element.numberSeqFormHandler().formMethodDataSourceCreatePre();
super(append);
if (!extern)
{
element.numberSeqFormHandler().formMethodDataSourceCreate(true);
}
}
Delete()
public void
delete()
{
element.numberSeqFormHandler().formMethodDataSourceDelete();
super();
}
Write()
public void
write()
{
super();
element.numberSeqFormHandler().formMethodDataSourceWrite();
}
Validate
Write()
public boolean
validateWrite()
{
boolean ret;
ret = super();
ret = element.numberSeqFormHandler().formMethodDataSourceValidateWrite(ret)
&& ret;
if (ret)
{
CarTable.validateWrite();
}
return ret;
}
Link Active()
public void
linkActive()
{
;
element.numberSeqFormHandler().formMethodDataSourceLinkActive();
super();
}
Now our numberseqence
is generated .
*** Set the field or Tabpage Allowedit property to No.
***Check the continues on wizard.
No comments:
Post a Comment