Translating a business case into a real-world extension

In this section, let's imagine having a Dynamics 365 Business Central customer with various business requirements. We want to create an extension to satisfy this customer's needs.

Our customer is a big commercial company that has adopted Dynamics 365 Business Central as the company's ERP and has various business requirements that require customization of the standard features to be satisfied.

The business requirements are as follows:

  • Sales: These requirements include the following:
    • The company wants to classify customers based on custom categories that they can define as needed and that can change in the future. Each Customer Category must have its own details that can be used for some business processes.
    • The sales office must be able to create a default Customer Category and assign this default value to a customer automatically.
    • The sales office needs the possibility to create gift campaigns for customer categories. A gift campaign is related to a limited period of time and a limited set of items.
    • A gift campaign can be set to inactive for a certain period of time.
    • When a gift campaign is active, the sales order manager must be able to automatically assign free gifts on a customer's sales order (they need a button on a sales order document that analyzes the order content, checks whether a campaign is active, and creates the free gift lines accordingly).
    • When a sales operator inserts a sales order line, they should be alerted if the customer is ordering an item quantity near to an active campaign promotion.
    • When a sales order is posted, the generated item ledger entry must store the Customer Category value (at the time of this order) for reporting purposes.
  • Vendor quality: These requirements include the following:
    • The company has a quality process in place (CSQ, international institute for the certification of business quality) and they need to classify vendors according to their CSQ requirements:
      • Score related to item quality (from 1 to 10)
      • Score related to delivery on time (from 1 to 10)
      • Score related to item packaging (from 1 to 10)
      • Score related to pricing (from 1 to 10)
    • The Vendor Quality Card must also display some financial data:
      • Invoiced for current year N
      • Invoiced for the year N-1
      • Invoiced for the year N-2
      • Amount due for this vendor
      • Amount to pay (not already due) for this vendor
    • The assigned scores determine a vendor rating (a numeric value) based on an algorithm.
    • The purchase office cannot release a purchase order if the vendor does not meet standard company requirements (the vendor rating).
    • The application's behavior could be extended in the future.

These customizations will be developed as a single extension by using the per-tenant range (50.000 – 99.999). We will use AppSource rules and we'll use the PKT tag (registered with Microsoft as our AppSource prefix/suffix) to target all of our objects. The project's .al files will be named according to the AppSource naming conventions.

We start our development tasks by opening Visual Studio Code and creating a new extension project (View | Command Palette | AL:GO!), selecting the Wave 2 release as the target.

We set the extension's manifest file (app.json) as follows:

{
"id": "dd03d28e-4dfe-48d9-9520-c875595362b6",
"name": "PacktDemoExtension",
"publisher": "SD",
"brief": "Customer Category, Gift Campaigns and Vendor Quality Management",
"description": "Customer Category, Gift Campaigns and Vendor Quality Management",
"version": "1.0.0.0",
"privacyStatement": "",
"EULA": "",
"help": "",
"url": "http://www.demiliani.com",
"logo": "./Logo/ExtLogo.png",
"dependencies": [
{
"appId": "63ca2fa4-4f03-4f2b-a480-172fef340d3f",
"publisher": "Microsoft",
"name": "System Application",
"version": "1.0.0.0"
},
{
"appId": "437dbf0e-84ff-417a-965d-ed2bb9650972",
"publisher": "Microsoft",
"name": "Base Application",
"version": "15.0.0.0"
}
],
"screenshots": [],
"platform": "15.0.0.0",
"features": [
"TranslationFile"
],
"idRanges": [
{
"from": 50100,
"to": 50149
}
],
"contextSensitiveHelpUrl": "https://PacktDemoExtension.com/help/",
"runtime": "4.0"
}

Here, we set the extension details, such as the name, publisher, version, description, the path of the logo image, the admitted object range IDs (from 50100 to 50149), and the supported runtime version.

We also set the following option:

"features": [
"TranslationFile"
]

The TranslationFile feature means that we want to have an XLIFF translation file that handles the multilanguage capabilities of this extension.

We want to organize our project structure with subfolders for functionalities and then for object types. Our base project structure will be as follows:

Here, we have an Src folder, and inside that, we have three main folders for functionalities:

  • CustomerCategory: This contains the implementation of the Customer Category requirements.
  • Gifts: This contains the implementation of the gift campaign requirements.
  • VendorQuality: This contains the implementation of the vendor quality requirements.

Inside each of these folders, we have subfolders organized into object types.

Let's start working on each of these three modules.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.93.136