Converting Dynamics GP SOP Master numbers to file system folder hierarchy

There are a number of cases where I need to store a document or documents against an “object” in GP for the various system integrations and modifications. This can be problematic, even more so with the latest update to Windows 10 that seemed to seriously detrimentally affect the performance of folders with large numbers of files or subfolders in them. Take the SOP document in GP. SOP documents are threaded together via a relationship called the master number. This master number relates all documents together between quote, order, invoice, return.

It is appropriate in some cases to store files against those master numbers. This could be done in a flat structure where a documents folder contains a sub folder for each master number and in side those folders lie the documents we wish to preserve. This starts out great, however by the time you end up with 500,000 sales master numbers and documents, opening the network store folder starts taking up to three to four minutes.  Although anything over a few thousand files or subfolders in a folder has always incurred a performance hit, with the new update this seemed to get a whole lot worse (it felt like a caching issue as subsequent re-opening of folder happened instantaneously).

Storing all those folders in a single folder is not a good user experience either, it is overwhelming to try and find a folder of interest among all those folders. A much better way is to store the folders in a hierarchy so there are never more than 1000 folders in each sub folder. This keeps the file system happy and quick.


So how to migrate the flat structure to hierarchy?


I love powershell and wish I could script in it more fluently than I can. Powershell seems to have the power to address any mundane task to do with windows servers and clients. Using power shell it is possible to move the flat structure into a new root directory, building it up into a hierarchy. My preference is for each folder to intuitively orientate the user as to where they are without having to digest/process too much of the path information.

There are lots of options for a directory arrangement scheme, but I like to do as follows, for a master number of 13224223, the folders can be organised like this:


This then necessitates a way to transform the number 13224223 to this directory arrangement. This is something regular expressions can help with, I’ve been using this technique for many, many years now.

Regular expression:


Replacement expression:


So integrating this into our powershell with optional date limit we get the following…

$sourcePath = "\\SalesArchive\"
$destPath = "\\SalesArchive\New\"
Get-ChildItem "$sourcePath\*" |? {$_.psiscontainer -and $_.lastwritetime -le (get-date).adddays(0)} |%{
if($_.Name -ne "New" -and $_.Name -ne "New2"){
$newFolder = ($destPath + "\" + ($_.Name -replace '([0-9a-zA-Z]*)([0-9a-zA-Z]{1})([0-9a-zA-Z]{1})([0-9a-zA-Z]{2})$','${1}0000\${1}${2}000\${1}${2}${3}00'));

New-Item -Path $newFolder -Type Directory -Force
Move-Item $_ $newFolder
Write-Host "source: $sourcepath dest: $newFolder"

This will move the folders into the new shape for us.

In .NET we can also use the same regular expression to open the folder or fetch/save files but using the .NET regular expression library something like this:

Return RootFolder & System.Text.RegularExpressions.Regex.Replace(DocumentMasterNumber,

Working things this way lets users access the folders instantly again and makes manual navigation of the folder structure possible, should it be needed.

Dynamics GP Font Size

Increasing font size for GP users with poor eyesight

Increase GP font sizes

Today one of my co-workers from the infrastructure team asked me to include a “magic file” into our standard GP deployment. The file is activated via a registry key on the user’s machine and provides them with a bigger font experience when using Dynamics GP in conjunction with font scaling on the windows operating system.

Font scale in windows

Font scaling in windows is found by typing into the start menu “scaling”…


Make everything bigger in Windows 10

Then you can scale up the system fonts…

Font scale in windows 10


Font Scale in GP

To make this sit well with Dynamics GP you need to apply this technique.

The required file is named “Dynamics.exe.manifest” and is dropped into the program files directory side by side with the application.  The contents of the manifest file are below:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
<assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="" processorArchitecture="*" publicKeyToken="6595b64144ccf1df" language="*">
<assemblyIdentity type="win32" name="Microsoft.VC90.CRT" version="9.0.21022.8" processorArchitecture="amd64" publicKeyToken="1fc8b3b9a1e18e3b">
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<requestedExecutionLevel level="asInvoker" uiAccess="false"/>
<asmv3:windowsSettings xmlns="">
<ms_windowsSettings:dpiAware xmlns:ms_windowsSettings="">false</ms_windowsSettings:dpiAware>


The manifest file is “activated” and the bigger font experience is enabled using a registry key change on the user machine:

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\SideBySide] "PreferExternalManifest"=dword:00000001


Thus the GP fonts are scaled up for the users that are using font scaling on the operating system.


It was also brought to my attention that newer builds of Windows 10 have a whole subsystem that is attempting to grapple with the DPI scaling issues. I would assume this is a UI for the same system that the manifest file is activating?

Right click on an executable and go down the rabbit hole…

Windows 10 Advanced DPI compatability menu




After being shown this, I realised I’d seen this “hack” before before and remembered it was from Steve Endow’s blog:

Fix Dynamics GP scaling and font size issues on high DPI displays

- where in this case he was trying to solve a slightly different problem with hi DPI displays, so thanks to Steve our users are benefitting every day from a more comfortable ERP experience.

Windows scaling issues for high-DPI devices



If you found this helpful do comment, it motivates me to blog more!

.NET 4.6.1 or 4.6.2 seem to break IsInRole()

Upgraded application using IsInRole(), now only returns false (

Read to the end before making code changes as there is a more obvious thing to check!
To support TLS1.2 for PCI requirements I was upgrading one of the applications to 4.6.1, after deployment behaviour controlled by our active directory groups was broken. It was like no one was a member of any AD groups anymore. First I thought it must be a coincidental screw up by someone in AD. It turns out it was something else…
The following code is used to check against a list of security groups to see if the current user belongs to any of them.
Public Shared Function IsInAdSecurityRole(RoleName() As String) As Boolean
Dim aName As String = Principal.WindowsIdentity.GetCurrent.Name
Dim aDomain As String = aName.Substring(0, aName.IndexOf("\") + 1)
For index = 0 To RoleName.Count - 1
If Thread.CurrentPrincipal.IsInRole(aDomain & RoleName(index)) Then
Return True
End If
Return False
End Function

The code is ancient, has been in our applications for a very long time but on upgrading to .NET framework 4.6.1 it returns false for all roles. Checked casing and ran in debug inspection and yet failed to see why it stopped behaving as it always had before.
Unable to figure out what had happened and with a need to get systems running again I imported the namespace System.Security.Principal
then using the following method all seems well again.
Public Shared Function IsInAdSecurityRole(RoleName() As String) As Boolean
Dim currPrincipal As New WindowsPrincipal(New WindowsIdentity(Environment.UserName))
For index = 0 To RoleName.Count - 1
If currPrincipal.IsInRole(RoleName(index)) Then
Return True
End If
Return False
End Function

I used this reference:

My.User.IsInRole() is not working after migrating to 4.6.2 framework in


Authentication mode in project settings Application-defined vs Windows

VB.NET has a setting in the project to say you wish to use application provided authentication method or use the default windows one. This was something that I had totally forgotten existed. It looks like the Authentication mode of the project got changed during the migration. Check the properties of the project, Authentication mode, see if changing it from Application-defined to Windows helps, it did in my case, bringing behaviour back to that which is expected.



Change the drop down combo box to “Windows”




Microsoft Dynamics GP–United Kingdom, Making Tax Digital (VAT) for business MTD / MTSfb

Update 23rd April 2019

April 2019 Hotfix for Dynamics GP - Making Tax Digital.
Microsoft have released a bug fix to the error:

You may incorrectly receive an error  in VAT Daybook Obligation period dates do not match with the VAT Daybook Calendar.

This occurs when logged in as the user SA, this bug fix also incorporates the full original update from Feb 2019.

Full details here: Microsoft Dynamics GP April Hotfix 2019 - more changes for VAT!!


Update 13th March 2019

Microsoft have released further details of the support added into Dynamics GP for MTD.

Microsoft Dynamics GP: 'Making Tax Digital' functionality for UK VAT


Update: 30th Jan 2019

Microsoft have released the following information post about VAT and Dynamics GP due to the questions raised by people preparing for Making Tax Digital. Worth a read here, Microsoft Dynamics GP: Information about the VAT 100 Return

Update: 26th Nov 2018

Although I know of some ISVs creating solutions for MTD, the first of the ISV solutions for GP to go public, from what I can see is m-hance. 

"Making Tax Digital for VAT" (MTDfV) - an offering from m-hance for Dynamics GP. See the details.

Keep an eye out for others ISVs publishing their solutions, over the months, as we lead up to mandatory deadline for electronic VAT submissions. 


Update: 3rd Aug 2018

Steven MacDonald @SteMac_mhance kindly pointed out on twitter in July that this requirement was being reviewed for inclusion in Dynamics GP2018 R2. 


Today, Ian in a post over on his blog, points out a status change on the MTD suggestion Microsoft Dynamics GP and Making Tax Digital

This certainly sounds promising from the MS Suggestion Site

We are in the process of implementing the changes needed for the Making Tax Digital initiative in the UK. Stay tuned for updates as to when this will be released. 

Original post:

Making Tax Digital is a Her Majesty's Revenue and Customs (HMRC) introducing a mandatory electronic filing of VAT (tax) returns by business by using an application that supports their application programming interface (API). VAT records must be maintained and submitted digitally after April 2019. HMRC are encouraging software developers to engage with them to create applications to interoperate with their APIs HMRC Blog - Digital Relationship Management – A new era in 3rd party software collaboration. Xero and other software companies have been working on the private Beta of the APIs for some time, but what about Microsoft?

HRMC - Overview of Making Tax Digital

HMRC Overview of Making Tax Digital


Dynamics GP, SMB products and Making Tax Digital VAT submission MTD

Microsoft Dynamics products AX, NAV, 365 Finance & Operations will all enable customers to be compliant,  the details of how is yet to become clear, perhaps bridging software?

Microsoft Dynamics community- Are you using our accounting software Dynamics NAV or Dynamics 365 Business Central and worried about compliance with Making Tax Digital?

Did you know the Microsoft SMB ERP products also include Dynamics GP too? -Dynamics GP already allows VAT to be recorded electronically and even has the VAT daybook functionally. You would think it not too great a leap to create a little helper application that could pluck the records from the database and submit them via the HMRC web API. It is disappointing that in April 2018 all we have from Microsoft is this page for users of GP.

VAT 2019 digital regulations for Microsoft Dynamics GP

that points to the suggestion list for new features for GP…

Suggestion: GP needs VAT electronic filing to be compliant with Making Tax Digital initiative

So one may think from this that there are no plans in action at the moment for it to be supported, on the other hand you could take the view this is Microsoft acknowledging the requirement, perhaps Terry may well have had her ear bent by the UK Dynamics partners thus creating this page? Admittedly it is a year away and the MS developers can work quite quickly when they need to. Also to be fair this product suggestion site is the funnel through which new features/requirements should be captured, so perhaps it is in hand?

However it would be nice to know soon if UK customers need to find another 3rd party bridging software to the HMRC APIs soon so we can start answering our Finance Directors and Controllers questions about what the plan is for 2019 (and yes that question sparked this blog post).



What is amusing is that HMRC have announced that spreadsheets are acceptable when used with bridging software to the APIs – heaven knows what accountants would do without them!

“Businesses will be able to continue to use spreadsheets for record keeping, but they must ensure that their spreadsheet meets the necessary requirements of Making Tax Digital for Businesses. This is likely to involve combining the spreadsheet with software.”

Accounting web- Spreadsheets for Making Tax Digital – The universal language of accounting


I will update this post if there are further developments over the year.