Number Sequence creation through code in axapta

Number sequence Creation

Add method current form where number sequence needed

 NumberSeqFormHandler numberSeqFormHandler;  
 NumberSeqFormHandler numberSeqFormHandler()  
 {  
 if (!numberSeqFormHandler)  
 {  
 numberSeqFormHandler = NumberSeqFormHandler::newForm(ProdParameters::numRefSrNo().NumberSequence,element,TableName_ds,fieldnum(TableName,SrNo));  
 }  
 return numberSeqFormHandler;  
 }  
 public void delete()  
 {  
 element.numberSeqFormHandler().formMethodDataSourceDelete();  
 super();  
 }  
 public void write()  
 {  
 ;  
 ttsbegin;  
 super();  
 element.numberSeqFormHandler().formMethodDataSourceWrite();  
 ttscommit;  
 }  
 void create(boolean _append = false, boolean extern = false) //If created externally  
 {  
 ;  
 element.numberSeqFormHandler().formMethodDataSourceCreatePre();  
 super(_append);  
 if (!extern)  
 {  
 element.numberSeqFormHandler().formMethodDataSourceCreate();  
 }  
 //GODInstrumentCalibrationHeader.Responsibility =curuserid();  
 To parametertable  
 server static NumberSequenceReference numRefSrNo()  
 {  
 return NumberSeqReference::findReference(typeId2ExtendedTypeId(typeid(SrNo)));  
 }  
 Add to class Number sequence reference like production  
 numRef.dataTypeId = typeId2ExtendedTypeId(typeid(SrNo));  
 numRef.referenceHelp = literalstr("Serial No.");  
 numRef.wizardContinuous = true;  
 numRef.wizardManual = NoYes::No;  
 numRef.wizardAllowChangeDown = NoYes::No;  
 numRef.wizardAllowChangeUp = NoYes::No;  
 numRef.sortField = 7;  
 this.create(numRef);  
 //end  
 public static NumberSeqModule numberSeqModule()  
 {  
 return NumberSeqModule::Prod;  
 }