Business Central – Want to try out the Multiple Posting Group Feature Update for Customer/Vendor?

In Business Central, there is a feature update, set to automatically enabled from Q4 2023, that allows using of multiple posting groups for customer or vendor. There are no options to try it out but to my knowledge, the function is available. Hmm, really?

It seems like there is a way to enable it if you want to go for a test drive in your sandbox environment. You will need to create an extension to add in the options for both “Purchases & Payables Setup” and “Sales & Receivables Setup”.

        modify("Allow Multiple Posting Groups")
        {
            ApplicationArea = All;
            Visible = false;
        }

In the code snippet below, visibility is set to false as I do not want to show it out since it has not been officially released yet. However, it still provides the option to add in the toggle flag via Personalization.

Backup – An Important Habit for Developers

Frequent backup of your codes and files is an important habit one should cultivate, especially if you are a software developer. Unfortunately, this is a forgotten trait, particularly for the newcomers. Acquiring this habit will save you from time to time, and probably your job.

Having frequent and multiple backups in the past saved me a lot of time in events such as accidental overwrites of codes, accidental deletion of files, encountering bugs that necessitate a rollback to the last working version. This habit has saved me a lot of hours and even days.

Just recently, I accidentally overwrote my python script that I had worked on for almost the whole day with other bash script while doing a file copy. Due to fatigue, I entered the wrong parameters for the file copy. Thankfully I had a version that was an hour old and I could work off from that.

That has not always been the case when I started out as a software developer. Back then, backup was an afterthought for a foolish young man like me and I paid the price occasionally after losing hours to days of work due to some accident. I had to burn through the night and re-do everything that was lost. It was a painful process.

Aside from making frequent backups, there is no harm in making multiple copies of a backup either. This was especially true in the age of floppy disks where storage reliability (even for hard disks at times) was much to be desired. I would be left in frustration after finding out my only backup was corrupted and I have to re-do my codes again.

There are many options for you to perform backup tasks. They can range from basic file backup solutions to file versioning control. Just choose something that you are comfortable with and roll with it.

  • Task Scheduler to run command line backup scripts
  • 3rd Party Automated Backup Solutions
  • Cloud Solutions
  • Git
  • Network Attached Storage / External Storage Devices
  • Others

Lastly, there can never be too much backup copies as long as you organise them properly.

Business Central – Problem with too much spaces?

The dreaded mental block have struck again and I was left pondering on how to remove spaces from a text variable for quite a while. The most straightforward way, a bit primitive, was to loop through each character and append those without spaces to a new string. But there has to be a better way. AL language has a function to remove leading and trailing spaces, what is left is the spaces in between words.

An example of what was to be achieved as listed below:

Before: SIMON & SPENCER

After: SIMON&SPENCER

I tried using Text.ConvertStr function but I got an error.

NewString := Text.ConvertStr(String: Text, FromCharacters: Text, ToCharacters: Text)

The ToCharacters cannot be an empty text. I was stuck.

After browsing to and fro, I finally found the answer. It has been staring at me all these while and it has been something I have been using so frequently. Introducing Text.DelChr. I don’t even have to do any trimming at all.

NewString := Text.DelChr(String: Text [, Where: Text] [, Which: Text])
MyOutputString := Text.DelChr(MyInputText, '=', ' ')

Using the above, all spaces in the text variable will be removed. Nice!

Business Central – BC14, C/SIDE, C/AL in 2022

First launched in 2018, Microsoft Dynamics 365 Business Central is an enterprise resource planning (ERP) system designed to replace its predecessors, Microsoft Dynamics NAV and Navision. One notable difference is that the platform is primarily cloud based and introduced a new AL language for development. C/SIDE and C/AL were supported from its initial release till Version 14 (BC14). In other words, BC14 is the last version that one is able to operate both C/SIDE and AL development environment. That is particularly useful when migrating to an extension based solution.

What is the deal with BC14, C/SIDE, C/AL in 2022 you might ask? Since it is a software-as-a-service, why are we still digging up the past and “reminiscing” about it? Shouldn’t be everyone on cloud and running the latest version of Business Central? Well, unfortunately, there are still some customers who are running Business Central 14 and below and retaining their customisation in C/AL, for reasons incomprehensible.

C/AL

First introduced around 1995, C/AL stands for Client/server Application Language. It is the programming language used within C/SIDE (Client/Server Integration Development Environment) aka classic development environment in Microsoft Dynamics NAV and some versions for Microsoft Dynamics Business Central. It resembles Pascal language and has been replaced by AL.

AL

Similar to C/AL it is the programming language that is used for manipulating data such as retrieving, inserting, and modifying records in a Dynamics 365 Business Central database. It controls the execution of the various application objects, such as pages, reports, or codeunits. AL is more modern, more efficient, open-source, and Cloud-enabled.

Why AL and not C/AL for Business Central?

C/AL development allowed flexibility in customizations, but it has also created a number of upgradeability challenges. In C/AL, all code changes were made at the core of the system. If you are writing codes to change how the system works, it takes time and effort to make sure that those customizations works when it is time to upgrade. AL takes a different approach. The standard Business Central core is basically an app, and any customization you published in the system is one or more apps. In this way, you can upgrade the core Business Central app with minimal impact to the rest of the customizations. Everything is neatly compartmentalized.

Why stay on BC14?

There is little reason why one should stay on with BC14. At this point of writing, Business Central is at Version 20 (BC20). There are some reasons given by customers who insisted on staying. Some of them involves the cost of migrating to an extension based solution, in-house tech preference of using C/AL for maintainability, misconception of increased maintenance, lack of control/ownership, among others. The more popular justification from customers are because of the windows client. Most of them conveyed that their end-users are used to the windows client and retraining them takes too much effort or they cannot adapt to it. Hence by maintaining status quo (using windows client), it would reduce the loss in productivity. So they claimed.

Should you upgrade?

To be honest, the prudent way forward is to upgrade. Why? Avoid technical debt. The longer one waits, the more costly it will be, in terms of effort and money. Upgrading to Business Central on cloud would ensure that you have the latest fix and feature upgrades. It would also be easier to maintain and support in future. You won’t be limited to windows client, you have access to new clients (web, mobile, tablet) without being constraint by your desktop. You get to enjoy better integration tools and options to future proof your business operations.

What are you thoughts and/or experience?

Business Central – How to download the PDF guide/manual

Once in a while, customers would call in to request a copy of the Business Central documentation/user guide/manual. Here is how you can guide them to get it.

Business Central Help Page

With reference to the above screenshot, do the following:

  1. Click on the “Question mark” at the top right of their Business Central page
  2. Click on the “Help & Support” link
  3. On the “Help & Support” page, click on the “Help” link as highlighted and identified as ‘3’ in the screenshot.
  4. A new window/tab to Microsoft Docs will open, alternatively you can directly go to the Microsoft Docs website (Link as shown below)

Welcome to Microsoft Dynamics 365 Business Central – Business Central | Microsoft Docs

Microsoft Docs Website for Business Central

Once on the Microsoft Docs website, click on the Download PDF link at the bottom left of the page (as shown above) to open or right click to download.

Business Central – Dude, Where’s the Warranty Date?

There is always something new to learn everyday in Business Central. I was doing some setup to test item tracking involving serial numbers and was fiddling with the warranty date required setting (See screenshot below). Somehow, the warranty column did not show up in the item tracking line page for both Purchase and Sales lines.

Item Tracking Card

After consulting one of the senior functional consultants, I learnt that the warranty column had to be manually added in via the personalization feature. The end result is as shown below.

Item Tracking Lines

Wonder why they couldn’t tie the visibility of the warranty date column to the setup. Am I missing anything?

Snakes and Camels?

I was intrigued by an email from a vendor that mentioned snakes and camel case for the field names from an API call. “What snakes and camels? Since when do animals come partying in our project?”, I wondered. These terms are quite rarely heard these days. Typically people deal with title case, uppercase, lowercase etc., so I decided to do some research to find out what is it about.

Camel case and snake case are different forms of variable naming convention style. These two are the more popular ones that programmers use. Camel case and snake case stand at opposite ends of the naming convention spectrum and we shall see how and what they are like in this article. You might even be using them without knowing what they are called, just like me.

Snake case uses underscore between words to create separation. As variable names cannot contain spaces, this reduces readability when multiple words are combined to describe its purpose. Snake case tries to minimize this shortcoming.

a_snake_case_name_looks_like_this

It is immediately apparent why it is called a snake case. It do looks like a snake wiggling amongst the codes. One study has found that readers can recognize snake case variable names more quickly than camel case.

Camel case uses capitalization of the first character of each word to denote the start of a new word. It is also known as Pascal case or upper camel case. When it is not, it is often referred to as lower camel case.

ACamelCaseNameLooksLikeThis

It is obvious why it is called a camel case. It does looks like it has a lot of humps doesn’t it. Do note that it is different from title case where it retains space as word separators. Camel case has been criticized as not been as readable compared to other methods due to the removal if spaces (and/or alternative replacements) and uppercasing of every word.

From the above examples, it seems pretty obvious that snake case provides better readability, but that is just my opinion. Some people find camel case easier to read. To me readability is especially important in coding. If your team member or others are unable to understand it, it is useless. The coding language and platform that you are using do affect your choice of naming convention. It is better to follow the standards (if there are any).

Business Central – CLEAR vs INIT function

What is the difference between CLEAR and INIT functions? Clear(Record) vs Record.Init()

CLEAR function

When used on a variable, i.e. Clear(SomeVariable), it simply clears the value that is stored to its default state. For example if it is a number variable, it will be set to 0 (zero), a date variable to undefined date (0D) and so on. Clear can be used on a Guid data type, and in this case sets the GUID to all zeroes.

When used on a record, i.e. Clear(Rec), or an array, all elements are cleared. It resets all the filters, resets the primary key and all fields will be initialized based on the InitValue property. If ChangeCompany is used, it will reset back to the original company.

INIT function

Used for initializing a new record in a table for insertion. It will assign default values to all the fields in the record, including the SystemId field.

Both of these functions might seem to be doing the same thing, setting fields to their default state, but they are used under different circumstances for different purposes.

Business Central – How to change primary key of a record

Typically when we want to update the contents of a record in BC, we would just use the modify function. For most cases, that would suffice, but what happens if the field you want to update is part of a composite primary key? Or when updating a record in which the content to be changed includes part of a primary key? In these scenarios, using the modify function will return an error. The solution? Read on!

Sample Record Structure

Here is a sample record structure for reference. In this case, we have a composite key consisting of “Entry No.” and “Line No.” as well as other data fields.

table 55047 "Sample Line Data"
{
    fields
    {
        field(1; "Entry No."; Integer)
        {
            Caption = 'Entry No.';
        }

        field(2; "Line No."; Integer)
        {
            Caption = 'Line No.';
        }
       
        field(3; "Item Code"; Code[10])
        {
            Caption = 'Item Code';
        }

        field(4; "Item Description"; Text[50])
        {
            Caption = 'Item Description';
        }
    }

    keys
    {
        key(PK; "Entry No.", "Line No.")
        {
            Clustered = true;
        }
    }
}

So what should we do if we need to change the following data: “Line No.” and “Item Description”?

We use the Rename function to update the “Line No.” which is part of the primary key, then re-retrieve the record and update the “Item Description” using the modify function.

The syntax for Rename function as show below.

[Ok := ]  Record.Rename(Value1: Any [, Value2: Any,…])

Code example as show below.

// #1 change part of primary key, line no from 1000 to 2000
if MyRecord.Get(1,1000) then
    MyRecord.Rename(MyRecord."Entry No.", 2000); 

// #2 get record again with new key
if MyRecord.Get(1, 2000) then
    begin 
        // #3 update item description (non key field)
        MyRecord."Item Description" := 'Changed Description';
        MyRecord.Modify();
    end;

Remember, do not change the sequence of the primary key!

Business Central – Code vs Text data type

When I first started doing NAV/BC development, I would get a bit confused over the purpose of Code and Text data type from time to time. After all, they are quite similar in function and role. Both of them store a string of text. It is also quite novel to me after working with Java, C++, VB.NET to see this type of data structure.

In the beginning, I assumed that Code data type’s role is for primary key and text is for everything else. While this is a fair assumption, I realized this is not the case as I gained experience over the years. There are use cases where you might want to use a code over text and in others text over code data types.

I have seen people using Code data type for storing record descriptions when a Text data type would be a better option. I have also made similar mistake when I started out, using a Code data type to store password when I should be using a Text data type.

Text data type denotes a text string, they are general purposes and comes with a lot of text manipulation functions. The Text data type is a value type, such that every time you use a method on it, you are creating a new text string object in memory. This means that there will be an allocation of space for each instance you are using it, which equates to overheads. It should not be a deal breaker unless you are dealing with and/or need to manipulate massive amount of textual data.

Code data type denotes a special type of string. The values are always converted and stored in uppercase and all leading and trailing spaces are removed. A Code variable cannot be null. That is what makes it so suitable for use as a primary/unique/referential key data type.