Set BCContainerHelper Default Configuration Values

BCContainerHelper is a PowerShell module that makes it easier to work with Microsoft Dynamics 365 Business Central and NAV Containers on Docker. The BCContainerHelper module contains many valuable functions that do much more than basic container management. I use this module in some form daily. Many BCContainerHelper module functions have switches and parameters; however, some use the default values with the options. 

You can configure BCContainerHelper default configuration values for use where applicable in the module functions.

This PowerShell script  demonstrates setting the configuration values for BCContainerHelper:

$bcContainerHelperConfig

$bcContainerHelperConfig.defaultNewContainerParameters = @{
"Accept_Eula" = $true
"Isolation" = "hyperv"
"UpdateHosts" = $true
}

$bcContainerHelperConfig | ConvertTo-Json | Set-Content "C:\ProgramData\BcContainerHelper\BcContainerHelper.config.json" 

Note: The code listed in this article is for demonstration purposes only 

June 2022 Cumulative Updates for Dynamics 365 Business Central and Microsoft Dynamics NAV

The June updates for Microsoft Dynamics NAV and Microsoft Dynamics 365 Business Central are now available.

Before applying the updates, you should confirm that your implementation is ready for the upgrade and ensure compatibility with your modifications. Work with a Microsoft Partner to determine if you are ready and what is needed for you to apply the update.

Please note that SaaS customers will automatically be upgraded to 20.2 over the coming days/weeks and should receive an email notification when upgraded.

Direct links to the cumulative updates are listed here:

Dynamics 365 Business Central On-Premises 2022 Release Wave 1 Updates – Update 20.2 (June 2022)

Dynamics 365 Business Central On-Premises 2021 Release Wave 2 Updates – Update 19.8 (June 2022)

Dynamics 365 Business Central On-Premises 2021 Release Wave 1 Updates – Update 18.14 (June 2022)

Dynamics 365 Business Central On-Premises 2020 Release Wave 2 Updates – Update 17.17 (April 2022)

Dynamics 365 Business Central On-Premises 2020 Release Wave 1 Updates – Update 16.17 (October 2021)

Dynamics 365 Business Central On-Premises 2019 Release Wave 2 Updates – Update 15.17 (April 2021)

Dynamics 365 Business Central On-Premises Spring 2019 Updates – Update 36 (June 2022)

Dynamics 365 Business Central On-Premises October’18 Updates – Update 18 (April 2020)

Microsoft Dynamics NAV 2018 – Update 53 (June 2022)

Microsoft Dynamics NAV 2017 – Update Update 61 (January 2022)

Microsoft Dynamics NAV 2016 – Update 67 (July 2021)

Validate field pattern with Regular Expression in Dynamics 365 Business Central

When accepting user input in a field, it may be necessary to validate that the value matches a particular pattern. In early versions of Microsoft Dynamics NAV, you could use the RegEx dotNet libraries to validate input against a regular expression.

The RegEx dotNet libraries are not directly available in Dynamics 365 Business Central; however, there is a RegEx Codeunit that provides functionality to use regular expressions to match text patterns. The RegEx Codeunit implements an IsMatch procedure, which you can use to validate a value against a Regular Expression.
For example, to match a pattern of three alphabetic characters followed by a hyphen and then any three alphanumeric characters (Good: ABC-D1Q, Bad: 123-ADS), the following RegEx example implementation demonstrates the use of the IsMatch procedure:

 Adjust the pattern and code to satisfy your requirements. Text version of code listed below.

field(50101; "DVLPR RegEx Code"; Code[20])
        {
            Caption = 'RegEx Code';
            DataClassification = CustomerContent;

            trigger OnValidate()
            var
                Matches: Record Matches;
                Regex: Codeunit Regex;
                Pattern,
                Value : Text;
            begin
                Pattern := '[A-Z]{3}\-[0-9,A-Z]{3}

                if Regex.IsMatch("DVLPR RegEx Code", Pattern, 0) then
                    Message('Match')
                else
                    Error('No Match');
            end;
        }

Note: The code listed in this article is for demonstration purposes only 

Business Central 2022 Wave 1 – In-Client Performance Profiler

With each update of Dynamics 365 Business Central, Microsoft enhances what is often referred to as the base application and enhances the development environment. Dynamics 365 Business Central 2022 Wave 1 has several exciting new features in the development environment. One of the exciting features is the In-Client Performance Profiler

In 2021 release wave 2, Microsoft added the AL performance profiler to the Visual Studio Code AL experience. The performance profiler has empowered pro developers to investigate performance as part of developing new functionality and help troubleshoot performance issues in AL code in customer environments.

In 2022 release wave 1, Microsoft takes the performance profiler even further. The in-client performance profiler is a new app page reached on its own or from the Help & Support page.

One note is that it is only possible to capture the current session for the user who starts the profiler in this release wave.

The In-client performance profiler is accessible from the Help and Support Page or by searching for Performance Profiler in the Tell Me feature of Business Central.

This tool makes it easy for consultants and customer administrators to perform initial performance investigations without involving pro developers seamlessly.
Once the In-Client Performance Profiler page is open, click the start action, and perform the operation you’d like to profile from the user session. Once the process completes, use the stop action to end profiling and display the profiler results.

The profiler will display the call tree and the amount of time consumed by each app and process within the call tree. The profiler data is precious information when determining where there may be a performance issue.

Set A Windows Service Log On Account and Password with PowerShell

Repeatability is important! Right alongside that, in my opinion, is efficiency. A recent task required me to set up several Application Services setups, including setting the log on account and password. I could have done all of these manually; however, I found it more efficient and repeatable to set up a script to handle the setup.

I won’t get into the portion for the setup of the services; I’ll communicate a few ways to set a Windows Service Log On Account and Password with PowerShell.

The Set-Service cmdlet changes the properties of a service, along with the starting and stopping of a service.

Before setting the log-on account information for a service, we need to capture the credentials. The credentials can come from user input:

# Prompt for credentials
$Credential = Get-Credential

# Prompt for credentials with message
$Credential = Get-Credential -UserName domain\user -Message 'Enter Password for Service Account'

or the credentials may be in the contents of the script:

$UserName = 'admin'
$Password = 'password'
$SecurePassword = ConvertTo-SecureString $Password -AsPlainText -Force
$Credential = New-Object System.Management.Automation.PSCredential ($UserName,$SecurePassword)

Once the credentials are captured, they are set for the service:

# Enter the name of the service to set; i.e. EventLog
$ServiceName = 'EventLog'

# Stop the service
Set-Service -Name $ServiceName -Status Stopped

# Set the service credentials
Set-Service -Name $ServiceName -Credential $Credential

# Start the service
Set-Service -Name $ServiceName -Status Running

The Get-Service cmdlet retrieves the properties of a service.

If you’re using an earlier version of PowerShell and do not have the -Credential parameter available, you can use the gwmi / Get-WmiObject cmdlet:

$account = "<the account name>"
$password = "<the account password>"
$servicename = "name='<the service name>'"

$svc = gwmi win32_service -filter $servicename
$svc.StopService()
$svc.change($null,$null,$null,$null,$null,$null,$account,$password,$null,$null,$null)
$svc.StartService()

Add Twitter Card to WordPress without Plugin

Reading this blog, one may think I focus on WordPress development and enhancements. That is not the case by any means. The focus of my career focused on the implementation of Microsoft Dynamics 365 Business Central. The concept behind this blog is to share bits of [technical] “stuff” that I encounter on my journey. The WordPress concepts come into play as I continue to enhance this site.

Sharing the content on this site on social platforms is another way to relay information that may be helpful to some. I recently became more active in the following Twitter posts and felt that it would be an excellent platform to share my blog posts. 

I went over to Twitter, pasted the link to a blog post that I wanted to share, and hoped to see a “preview” of the content. Well, I was wrong. The only thing in the “tweet” was the link to the post. After a bit of digging, I found that there is a “Twitter Card.” The Twitter Card is meta-information on the page of your site that relays to Twitter how the page preview should look in a Tweet. I found that there is a Twitter Card Validator that will alert you of any Twitter Card issues for the link that you’d like to Tweet. Of course, my post failed validation.

Several WordPress Plugins are available that add Twitter Cards to your pages, but I prefer to use as few Plugins as possible to reduce the risk of any issues. Just as I did when changing the Login Page, I opted to get the Cards onto my posts myself through functions and actions.

Add the following to your Theme’s functions.php file (replace the image url and the twitter creator tag with your image and tag):

function twittercard()
{
	if(is_single() || is_page()) {
    	$twitter_title  = get_the_title();
		$twitter_url    = get_permalink();
		$twitter_desc   = get_the_excerpt();
		$twitter_image	= 'https://www.dvlprlife.com/tweetimage.jpg?rating=PG&size=75';
		
		echo '<meta name="twitter:card" value="summary" />';		
		echo '<meta name="twitter:title" value="'  . $twitter_title . '" />';
		echo '<meta name="twitter:url" value="' . $twitter_url . '" />';
		echo '<meta name="twitter:description" value="' . $twitter_desc . '" />';
		echo '<meta name="twitter:image" value="' . $twitter_image . '" />';

		echo '<meta name="twitter:creator" value="@dvlprlife" />';
	}
}

add_action('wp_head', 'twittercard');

 

Please note that doing this without a plugin does require some programming knowledge, and before ever making any changes, you should always back up your site.

Make a note and save the code added; if the function.php file is updated and replaced, the code will need to be added to the file again. You can also look into setting child themes to keep you from losing the edit.

Delete files within subfolders older than a certain period using PowerShell

In keeping true to the concept of this blog, “Follow the life of an ERP developer, one post at a time,” this post allows you to “follow” something that I needed to crush – deleting files older than a specific number of days or hours including subfolders.

Many moons ago, I created an application that created log files capturing event details. The log files’ sole Delete Key In Bluepurpose was to review events and troubleshoot issues when processing these events. The files are saved in a folder structure divided and grouped by Year, Month, and Event Type. The grouping is helpful for troubleshooting and finding specific transactions, but with several types of events and, at times, a decent volume, there can be a decent amount of disk space wasted; realistically, there isn’t a need to keep diagnostic logs forever. The data does become stale after a certain period.
I created this PowerShell script to delete files from a folder and subfolders older than a certain number of hours from the time of script execution:

$sourcepath = 'D:\Archive\'
$CurrDate = Get-Date
$MaxHours = -1200

Foreach($folder in (Get-ChildItem $sourcepath -Recurse  | where {  $_.PSIsContainer }))
{
    #"Folder: $folder"
    Foreach($file in (Get-ChildItem $folder.FullName | where { ! $_.PSIsContainer }))
    {
	#"File: $file"
        if($file.LastWriteTime -lt ($CurrDate).AddHours($MaxHours))
        {
	        #"Filter File: $file"
            Write-Host -ForegroundColor Yellow ($file.FullName) 
            Remove-Item $file.FullName
        }
    }
}

If you want to specify the number of days, replace:

if($file.LastWriteTime -lt ($CurrDate).AddHours($MaxHours))

with

if($file.LastWriteTime -lt ($CurrDate).AddDays($MaxDays))

Remember to replace the $MaxHours variable with $MaxDays.

How to Delete a Sprint in Azure DevOps

When working with Project Planning in Azure DevOps, Sprints are easy to create and assign to Work Items. While there is an easy way to make a Sprint, the option to delete a sprint in Azure DevOps isn’t quite as obvious. It may not often be that you want to delete a sprint (which may be why it isn’t glaring us in the face), but if you play around with Planning and Sprints, you may find yourself needing to delete a sprint (or more) from a project in Azure DevOps

To delete a Sprint in AzureDevOps:

  1. Go to Project Settings
  2. Go into the Project Configuration in the Boards section of the Project Settings
  3. Find the sprint that you’d like to delete and click the ellipsis to open up an additional Menu
  4. Click Delete Menu Item

Delete a sprint in Azure DevOps

Deleting a Sprint may not be something you may not need to do often, but if you do – now you know!

May 2022 Cumulative Updates for Dynamics 365 Business Central and Microsoft Dynamics NAV

The May updates for Microsoft Dynamics NAV and Microsoft Dynamics 365 Business Central are now available.

Before applying the updates, you should confirm that your implementation is ready for the upgrade and
ensure compatibility with your modifications. Work with a Microsoft Partner to determine if you are ready and what is needed for you to apply the update.

Please note that SaaS customers will automatically be upgraded to 20.1 over the coming days/weeks and should receive an email notification when upgraded.

Direct links to the cumulative updates are listed here:

Dynamics 365 Business Central On-Premises 2022 Release Wave 1 Updates – Update 20.1 (May 2022)

Dynamics 365 Business Central On-Premises 2021 Release Wave 2 Updates – Update 19.7 (May 2022)

Dynamics 365 Business Central On-Premises 2021 Release Wave 1 Updates – Update 18.13 (May 2022)

Dynamics 365 Business Central On-Premises 2020 Release Wave 2 Updates – Update 17.17 (April 2022)

Dynamics 365 Business Central On-Premises 2020 Release Wave 1 Updates – Update 16.17 (October 2021)

Dynamics 365 Business Central On-Premises 2019 Release Wave 2 Updates – Update 15.17 (April 2021)

Dynamics 365 Business Central On-Premises Spring 2019 Updates – Update 35 (May 2022)

Dynamics 365 Business Central On-Premises October’18 Updates – Update 18 (April 2020)

Microsoft Dynamics NAV 2018 – Update 52 (May 2022)

Microsoft Dynamics NAV 2017 – Update Update 61 (January 2022)

Microsoft Dynamics NAV 2016 – Update 67 (July 2021)

Business Central 2022 Wave 1 – Users can Export Report Datasets to XML

With each update of Dynamics 365 Business Central, Microsoft enhances what is often referred to as the base application and enhances the development environment. Dynamics 365 Business Central 2022 Wave 1 has several exciting new features in the development environment. One of the exciting features is that Users can Export Report Datasets to XML.

Users and developers can get report datasets in XML format, which they can then archive, use for integration scenarios or troubleshoot the reports during development.

Similar to the Export dataset to Excel (no layout) capability added in Dynamics 365 Business Central 2021 release Wave 1, business users and developers can now get report datasets in XML directly from the Send to section of the request page.

To export the data to an XML file:

  • Open the report request page and enter the desired filters
  • Click the Send to action
  • Choose XML and then OK

The Send to XML document renders the report data to an XML file.