Creating number Sequence In D365
FO:
Today I want to
describe about how to create number sequence in D365 FO
Step 1 :
Create EDT like String and add this EDT in
Table field.
Step 2 :
Create a new extension class of table
VendParmeters and a new method. Example:
[ExtensionOf(tableStr(VendParameters))]
final class VendParameters_Extension
{
public static
NumberSequenceReference numseqID ()
{
return NumberSeqReference::findReference(extendedTypeNum(EDTName));
}
}
Step 3 :
Create a new extension class of
NumberSeqModuleVendor.
[ExtensionOf(classStr(NumberSeqModuleVendor))]
final class NumberSeqModuleVendor_Extension
{
protected void
loadModule()
{
NumberSeqDatatype
datatype = NumberSeqDatatype::construct();
next
loadModule();
datatype.parmDatatypeId(extendedTypeNum(EDTName));
datatype.parmReferenceHelp(literalStr("EDT
Label"));
datatype.parmWizardIsContinuous(false);
datatype.parmWizardIsManual(NoYes::No);
datatype.parmWizardFetchAheadQty(10);
datatype.parmWizardIsChangeDownAllowed(NoYes::No);
datatype.parmWizardIsChangeUpAllowed(NoYes::No);
datatype.parmWizardHighest(999999);
datatype.parmSortField(1);
datatype.addParameterType(NumberSeqParameterType::DataArea,
true, false);
this.create(datatype);
}
}
Step 4 :
Create a runnable class
NumberSeqModuleVendorRunnableClass which will load the number
sequences.
class NumberSeqModuleVendorRunnableClass
{
///
<summary>
///
Runs the class with the specified arguments.
///
</summary>
///
<param name = "_args">The specified arguments.</param>
public static void main(Args _args)
{
NumberSeqModuleVendor
loadModule = new NumberSeqModuleVendor();
;
loadModule.load();
}
}
Step 5 :
Run above class . Then Generate number sequence
in organization Administartion module.
Path : (Organization Administration >
numbersequences > Numbersequences > Generate > run the wizard).
Step 6 :
Now we want that Number Sequence
in form level:
Declare the number sequence On Form Declaration:
public class FormRun extends ObjectRun
{
NumberSeqFormHandler
numberSeqFormHandler;
}
Write the NumberSeqFormHandler()
in form methods node.
NumberSeqFormHandler
numberSeqFormHandler()
{
if (!numberSeqFormHandler)
{
numberSeqFormHandler =
NumberSeqFormHandler::newForm(VendParameters::numseqID().NumberSequenceId,element,“DataSource Name”_DS,
fieldNum(TableName, fieldName));
}
return numberSeqFormHandler;
}
Write the close() on the form methods node.
void close()
{
if (numberSeqFormHandler)
{
numberSeqFormHandler.formMethodClose();
}
super();
}
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)
{
TableName.validateWrite();
}
return ret;
}
Link Active()
public void linkActive()
{
;
element.numberSeqFormHandler().formMethodDataSourceLinkActive();
super();
}
Now our numberseqence is generated .
Comments
Post a Comment