Tuesday, July 30, 2019

New number sequence in D365

Issue: How to create a new number sequence in D365?

Solution: 1. Create a new EDT for eg. TSTCustomsJourId.
                2. Extend standard "NumberSeqModule" enum and add a new enum value e.g NumberSeqModule::TSTCustoms.
             
Implement below class and methods.

class TSTNumberSeqModuleCustoms extends NumberSeqApplicationModule
{
    /// <summary>
    /// Sets up the references for the <c>TSTCustoms</c> module number sequences.
    /// </summary>
    protected void loadModule()
    {
        NumberSeqDatatype datatype = NumberSeqDatatype::construct();

        /* Setup document numbers */
        datatype.parmDatatypeId(extendedtypenum(TSTCustomsJourId));
        datatype.parmReferenceHelp(literalstr("TST:CustomsHelpText"));
        datatype.parmWizardIsContinuous(false);
        datatype.parmWizardIsManual(NoYes::No);
        datatype.parmWizardfetchAheadQty(10);
        datatype.parmWizardIsChangeDownAllowed(NoYes::No);
        datatype.parmWizardIsChangeUpAllowed(NoYes::No);
        datatype.parmSortField(1);

        datatype.addParameterType(NumberSeqParameterType::DataArea, true, false);
        this.create(datatype);
    }

    /// <summary>
    /// Gets the number sequence module that the current object is attached to.
    /// </summary>
    /// <returns>
    /// The number sequence module that the current object is attached to.
    /// </returns>
    public NumberSeqModule numberSeqModule()
    {
        return NumberSeqModule::TSTCustoms;
    }

    /// <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(TSTNumberSeqModuleCustoms), numberSeqModuleNamesMap);
    }

}

No comments:

Post a Comment