D365 Number Sequence Reference
Step: 1. Create new class and extend it to NumberSeqApplicationModule:
public class NumberSeqModuleMP extends NumberSeqApplicationModule
{
/// <summary>
/// Configures all the data types that are being used by the module.
/// </summary>
/*
Detailed description of how to setup references for number sequences can
be found i method loadModule() on the 'father' class: NumberSeqApplicationModule.
*/
protected void loadModule()
{
datatype.parmDatatypeId(extendedTypeNum(MPDependentId));
datatype.parmReferenceHelp(literalStr("@MPL:DependentId"));
datatype.parmWizardIsContinuous(False);
datatype.parmWizardIsManual(NoYes::No);
datatype.parmWizardIsChangeDownAllowed(NoYes::No);
datatype.parmWizardIsChangeUpAllowed(NoYes::No);
datatype.parmSortField(13);
datatype.addParameterType(NumberSeqParameterType::DataArea, true, false);
this.create(datatype);
}
/// <summary>
/// Retrieves the ID of the application-specific module for this class.
/// </summary>
/// <returns>
/// The module-specific ID.
/// </returns>
public NumberSeqModule numberSeqModule()
{
return NumberSeqModule::MP;
}
/// <summary>
/// Appends the current class to the map that links modules to number sequence data type generators.
/// </summary>
[SubscribesTo(classstr(NumberSeqGlobal),delegatestr(NumberSeqGlobal,buildModulesMapDelegate))]
static void buildModulesMapSubsciber(Map numberSeqModuleNamesMap)
{
NumberSeqGlobal::addModuleToMap(classnum(NumberSeqModuleMP), numberSeqModuleNamesMap);
}
}
Step: 2. In Param Table of that Module Add below method:
client server static NumberSequenceReference numRefMPDependentID()
{
return NumberSeqReference::findReference(extendedTypeNum(MPDependentId));
}
Step: 3. Go to the Form where you need to add number sequence:
1. Add Below code to Form Class declaration:
[Form]
public class MyDependentEssEntry extends FormRun
{
NumberSeqFormHandler numberSeqFormHandler;
}
2. Form Close Method:
void close()
{
;
if (numberSeqFormHandler)
numberSeqFormHandler.formMethodClose();
super();
}
3. Create Below Method:
NumberSeqFormHandler numberSeqFormHandler()
{
if (!numberSeqFormHandler)
{
numberSeqFormHandler = numberSeqFormHandler::newForm(MPParameters::numRefMPPayCycle().NumberSequenceId,
element,
MPPayCycles_DS,
fieldNum(MPPayCycles, MPPayCycleID)
);
}
return numberSeqFormHandler;
}
4. OverRide Datasource create Method as below:
public void create(boolean _append = false)
{
element.numberSeqFormHandler().formMethodDataSourceCreatePre();
super(_append);
element.numberSeqFormHandler().formMethodDataSourceCreate();
}
public void linkActive()
{
element.numberSeqFormHandler().formMethodDataSourceLinkActive();
super();
}
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 class NumberSeqModuleMP extends NumberSeqApplicationModule
{
/// <summary>
/// Configures all the data types that are being used by the module.
/// </summary>
/*
Detailed description of how to setup references for number sequences can
be found i method loadModule() on the 'father' class: NumberSeqApplicationModule.
*/
protected void loadModule()
{
datatype.parmDatatypeId(extendedTypeNum(MPDependentId));
datatype.parmReferenceHelp(literalStr("@MPL:DependentId"));
datatype.parmWizardIsContinuous(False);
datatype.parmWizardIsManual(NoYes::No);
datatype.parmWizardIsChangeDownAllowed(NoYes::No);
datatype.parmWizardIsChangeUpAllowed(NoYes::No);
datatype.parmSortField(13);
datatype.addParameterType(NumberSeqParameterType::DataArea, true, false);
this.create(datatype);
}
/// <summary>
/// Retrieves the ID of the application-specific module for this class.
/// </summary>
/// <returns>
/// The module-specific ID.
/// </returns>
public NumberSeqModule numberSeqModule()
{
return NumberSeqModule::MP;
}
/// <summary>
/// Appends the current class to the map that links modules to number sequence data type generators.
/// </summary>
[SubscribesTo(classstr(NumberSeqGlobal),delegatestr(NumberSeqGlobal,buildModulesMapDelegate))]
static void buildModulesMapSubsciber(Map numberSeqModuleNamesMap)
{
NumberSeqGlobal::addModuleToMap(classnum(NumberSeqModuleMP), numberSeqModuleNamesMap);
}
}
Step: 2. In Param Table of that Module Add below method:
client server static NumberSequenceReference numRefMPDependentID()
{
return NumberSeqReference::findReference(extendedTypeNum(MPDependentId));
}
Step: 3. Go to the Form where you need to add number sequence:
1. Add Below code to Form Class declaration:
[Form]
public class MyDependentEssEntry extends FormRun
{
NumberSeqFormHandler numberSeqFormHandler;
}
2. Form Close Method:
void close()
{
;
if (numberSeqFormHandler)
numberSeqFormHandler.formMethodClose();
super();
}
3. Create Below Method:
NumberSeqFormHandler numberSeqFormHandler()
{
if (!numberSeqFormHandler)
{
numberSeqFormHandler = numberSeqFormHandler::newForm(MPParameters::numRefMPPayCycle().NumberSequenceId,
element,
MPPayCycles_DS,
fieldNum(MPPayCycles, MPPayCycleID)
);
}
return numberSeqFormHandler;
}
4. OverRide Datasource create Method as below:
public void create(boolean _append = false)
{
element.numberSeqFormHandler().formMethodDataSourceCreatePre();
super(_append);
element.numberSeqFormHandler().formMethodDataSourceCreate();
}
public void linkActive()
{
element.numberSeqFormHandler().formMethodDataSourceLinkActive();
super();
}
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();
}
Comments
Post a Comment