- Create a new Extended Data Type (EDT)
- Create a new class that extends the NumberSeqModuleInventory class and then create the COC method to loadModule and add the following code:
[ExtensionOf(classStr(NumberSeqModuleInventory))]
final class NumberSeqModuleInventoryDOM_Extension
{
/// <summary>
/// Configures all the data types that are being used by the module.
/// </summary>
protected void loadModule()
{
next loadModule();
NumberSeqDatatype datatype = NumberSeqDatatype::construct();
//Setup Order Id
datatype.parmDatatypeId(extendedtypenum(DOMOrderId));
datatype.parmReferenceHelp(literalstr("Key identifier for Order details"));
datatype.parmWizardIsContinuous(false);
datatype.parmWizardIsManual(NoYes::Yes);
datatype.parmWizardIsChangeDownAllowed(NoYes::No);
datatype.parmWizardIsChangeUpAllowed(NoYes::No);
datatype.parmSortField(20);
datatype.addParameterType(NumberSeqParameterType::DataArea, true, false);
this.create(datatype);
}
}
- Create a new extension class of table InventParameters and a new method.
[ExtensionOf(tableStr(InventParameters))]
final class InventParametersDOM_Extension
{
public static NumberSequenceReference numRefDOMOrderId()
{
return NumberSeqReference::findReference(extendedTypeNum(DOMOrderId));
}
}
- Create a runnable class NumberSeqModuleInventoryRunnableClass which will load the number sequences.
class NumberSeqModuleInventoryRunnableClass
{
public static void main(Args _args)
{
NumberSeqModuleInventory loadModule = new NumberSeqModuleInventory();
;
loadModule.load();
}
}
- At last, go to Organization administration – Number sequences – Number sequences – Generate Button (Run the wizard and complete it)
- Add EDT in the table
- Add field in the form
Add the following code on the Class declaration node
NumberSeqFormHandler numberSeqFormHandler;
- Create a new method on the form and write the following code
NumberSeqFormHandler numberSeqFormHandler()
{
if (!numberSeqFormHandler)
{
numberSeqFormHandler = NumberSeqFormHandler::newForm(
NumberSeqReference::findReference(extendedtypenum(DOMOrderId)).NumberSequenceId, element,DOMOrderTable_ds,fieldnum(DOMOrderTable, OrderId));
}
return numberSeqFormHandler;
}
Override the close method of the form
public void close()
{
if (numberSeqFormHandler)
{
numberSeqFormHandler.formMethodClose();
}
super();
}
DataSource methods
public void create(boolean _append = false)
{
element.numberSeqFormHandler().formMethodDataSourceCreatePre();
super(_append);
element.numberSeqFormHandler().formMethodDataSourceCreate(true);
}
public void write()
{
super();
element.numberSeqFormHandler().formMethodDataSourceWrite();
}
public boolean validateWrite()
{
boolean ret;
ret = super();
ret = element.numberSeqFormHandler().formMethodDataSourceValidateWrite(ret) && ret;
return ret;
}
public void delete()
{
element.numberSeqFormHandler().formMethodDataSourceDelete();
super();
}
public void linkActive()
{
element.numberSeqFormHandler().formMethodDataSourceLinkActive();
super();
}
Reference :- https://www.dynamics101.com/creating-custom-number-sequences-microsoft-dynamics-ax-2012/
Thanks for sharing information. Nice blog
ReplyDeleteD365 Ax Technical online training
D365 finance and operations online training