Creating a module in Microsoft Dynamics 365: Setting Up the Number Sequence Module [part 5]

This post is part of a series on creating a module within a Microsoft Dynamics 365 for Finance and Operations application. Links to the other parts are available in the first post: Creating a Module in Microsoft Dynamics 365: Laying the Foundation.

A module in Microsoft Dynamics 365 for Finance and Operations is a grouping of similar business processes and functions that allow users to conduct business. Examples include General Ledger, Accounts Receivable, Accounts Payable, and many others. Developers create new modules to group new functionality in an equivalent manner or to produce third-party solutions.

In this series, I am creating a fictitious module called Generic Application Solution (GAS). The assumption will be that the reader has an intermediate knowledge of development in Dynamics 365 as well as best practices. This post will build upon the last post by creating the number sequence module.

In order to add a number sequence module, developers will need to add the Directory and the Tax packages to the list of the model’s dependencies. These dependencies become important when adding the number sequence tab to the parameters form.

Extending the NumberSeqModule Enumeration

The first step in creating a number sequence module is to extend the NumberSeqModule enumeration. This enumeration is one of the places in Dynamics 365 where developers define the module.

Properties of a new element added to the NumberSeqModule enumeration

In the AOT, developers will create an extension of the NumberSeqModule and create a new element on the enumeration in the designer. The key properties are Configuration Key and Label.

Creating the NumberSeqModule Class

The next step is to create a class that defines the programmatic elements of the number sequence module. This class must extend the NumberSeqApplicationModule class. It is a best practice to name it “NumberSeqModule” followed by the abbreviated name of the module. In this exercise, the name of the class will be “NumberSeqModuleGAS.” The following code is the skeleton of this class.

/// <summary>
/// Number sequence module class for GAS module
/// </summary>
class NumberSeqModuleGAS extends NumberSeqApplicationModule
{
    /// <summary>
    /// standard method for implementing new number sequence module
    /// </summary>
    /// <returns>NumberSeqModule value</returns>
    public NumberSeqModule numberSeqModule()
    {
        return NumberSeqModule::GAS;
    }

    /// <summary>
    /// standard method for implementing new number sequence module
    /// sets up number sequences for module identifiers
    /// </summary>
    protected void loadModule()
    {
        NumberSeqDatatype datatype = NumberSeqDatatype::construct();

        // TODO: Add code for data types associated with the module
    }

    /// <summary>
    /// event handler for implementing new number sequence module
    /// adds the module to the global map
    /// </summary>
    /// <param name="numberSeqModuleNamesMap">global map for number sequence modules</param>
    [SubscribesTo(classStr(NumberSeqGlobal), delegateStr(NumberSeqGlobal, buildModulesMapDelegate))]
    public static void NumberSeqGlobal_buildModulesMapDelegate(Map numberSeqModuleNamesMap)
    {
        NumberSeqGlobal::addModuleToMap(classnum(NumberSeqModuleGAS), numberSeqModuleNamesMap);
    }
}

Developers will add code to the loadModule method to add support for data types that have a number sequence.

Adding the Module to the Parameters Table

The final step in creating the number sequence module is to add a method to the parameters form. This simple static method just returns the module’s element from the NumberSeqModule enumeration.


    public static NumberSeqModule numberSeqModule()
    {
        return NumberSeqModule::GAS;
    }

That concludes the creation of the number sequence module, however, the module does not have a user interface. It is best practice to add a number sequence tab to the parameters form. I will be covering that in the next post.

References

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s