Dynamic Code Blocks

Microsoft Dynamics GP & .NET technical Blog by Tim Wappat

Irish Tax Registration Number in Dynamics GP (continued)

Irish VAT numbers of new format fail GP validation, here we fix the issue.

The previous post GP2010 SP3 Enhanced Intrastats VAT number format wrong IE (Ireland) and others…identified an issue with the validation on the Tax Registration Number in the Intrastat Setup Window for Dynamics GP addresses. Ireland have introduced a new format for VAT numbers that allows two alpha characters, the following is the full specification:

1234567X, 1X23456X, 1234567XX, (8 or 9 characters. Includes one or two alphabetical characters (last, or second and last, or last 2))


If a VAT number is entered in the format 1234567XX, GP will not accept it, preventing the user for leaving that window until a valid format is entered. This was raised with Fargo, but nothing came back from them and it is still a problem today in version GP2013R2. One would expect a SQL table keyed on country code, that holds regular expressions to feed this validator, thus they can be easily changed when this sort of event occurs. Instead it looks like the validation is hard coded in the Dexterity scripts.

Well, if you can’t get a job done properly, do it yourself. Our sales team are starting to hit this issue more often now that the new codes have been available for a little while and more new companies have been allocates these new format codes. This ear ache called for a fix…

Fixing it

Script logging tells us that the validator function is:

'eiProc_IsValidFormat_GBTaxRegNumber()', 0, "IE", "1234567RH"

Wonderful - this looks like a quick and easy fix…

Run the DAG against the Intrastat module to get the.NET assemblies, in my case and with my install that is:

'Advanced Intrastats
"C:\Program Files (x86)\Microsoft Dynamics\GP2013 VS Tools SDK\DAG.exe" 2788 /M /O
"C:\Program Files (x86)\Microsoft Dynamics\GP2013 VS Tools SDK\DAG.exe" 2788 /F /O

Reference the assemblies in the addin project,


Now create an after script “trigger” (.NET event handler) against this script in GP on the init of the addin.

'----------------------- EnhancedIntrastat -----------------------------
AddHandler EnhancedIntrastat.Functions.EiProcIsValidFormatGbTaxRegNumber.InvokeAfterOriginal, AddressOf AfterEiProcIsValidFormatGbTaxRegNumber

Write a regular expression to validate the field. Try the regular expression tester extension for Visual Studio, go to the gallery (extensions and updates) to install it, then test the expression.



This is not a optimum expression, but this post is intended for audience that may familiar with regular expressions, so it is in a form that is accessible to be easily understood.

Finally write the override method called by the after event of that script to change the result to true or false for IE based on the corrected regular expression validation.

Private Sub AfterEiProcIsValidFormatGbTaxRegNumber(sender As Object, e As 
'Override the built in check and replace with the correct checking
If e.inParam1 = "IE" Then
If System.Text.RegularExpressions.Regex.IsMatch(e.inParam2,
"^(IE){0,1}[0-9]{7}([0-9][A-Z]|[A-Z]{2})|(IE){0,1}[0-9][0-9A-Z][0-9]{5}[A-Z]$") Then
e.result = True
e.result = False
End If
End If
Catch ex As Exception
End Try
End Sub

Compile, deploy, test and the form will now correctly validate the new numbers. The regular expression will actually go into a SQL table as the next iteration of this code, the network support team will then be able to add more exceptions to the validation rules in the future without a deployment, should any other countries change formats.

GitHub can't sync “pre-receive hook declined”

How I solved my git problem pre-receive hook declined

For my Makerfaire .NET Microframework embedded work I’ve been using the wonderful Git integration within Visual Studio. For my repository, I’ve been using GitHub as I don’t mind it being public.

It has been a great experience so far, as I’ve been brought up on Visual Source Safe then Team Foundation Server, the way Git works has taken me some time to get used to, but the integrated tools has made the learning easier.


The other day I put some documentation into my project, one file was a Microsoft Publisher file that was extremely large as it held the graphics for my printed displays at the faire. I innocently committed the files into my local repository, then tried  to push it to GitHub. I got the

“pre-receive hook declined”

Error when trying to sync. It seems, quite reasonably, that there is a file size limit on what  can be added. However i’d made another commit since adding the file.

So for the future I document for myself how I got out of the problem.

First you have to get the command prompt git working. Go to Git Settings, on your version of the screen below it will have hyperlink to install 3rd party tools. Follow the link and install them.


Right click around the various windows and some of them have the option to open the command prompt, do so.




I ran the git rm command but using a directory filter to remove all instances of .pub files from my repository, going right back through all my history. The HEAD command says go to now and I could have specified a commit ID to limit the activity to one commit, but this was not needed. Git rewrote all my commits and so I finally pushed the changes back.


Job done!

Git is syncing ok now and I can move on with my prep for Makerfaire uk 2015.

Modal GP Add-in window launching Dex form causes backspace and tab weird characters - Microsoft Dynamics GP

Description of problem found launching Dex windows from Dynamics GP addin

I have found an issue when launching a Dexterity GP windows form from an addin form that is being shown modally. The launched Dexterity form generates funny characters when the backspace key is pressed and the Tab key does not work.

For example, use this code from a button click even on a new windows form that is being shown modally:

Microsoft.Dexterity.Applications.SmartListDictionary.VendorLookupForm window = Microsoft.Dexterity.Applications.SmartList.Forms.VendorLookup;


Once the lookup launches, if the user presses the back-space key while they have focus on the “Find by …” box, then strange characters are inserted. We would expect instead for the text to be deleted, you can see in the screen shot, within the highlighted region an example of those characters. If the same actions are taken, only this time the origin form is a non-modal windows form, then the characters to the left of the caret are removed, as we would normally expect.

(Ignore the pixelated content in the Creditors screenshot below, done from privacy.)


It would seem to be the same as this post: "Invalid characters when when opening a dex form via a modal .net form" http://dyndeveloper.com/thread.aspx?Threadid=1656

I would love a work around or more information on why this happens as it means not being able to use any of the GP lookup windows from a modal windows form in an add-in, or finding a UI story that works without modal dialogs, something I’d rather not have to develop.

If you can offer any assistance, please comment on this post.

This has also been posted on the GP forums here: https://community.dynamics.com/gp/f/32/t/155082.aspx


In our add-in, currently each lookup gets its own .NET duplicate of the built in lookup.

  • We have to build bespoke for each type of field required
  • This duplicate lacks some of the built in functionality that native lookups have (advanced searching/favourites/multicolumn/expand rows etc)
  • For the users, the experience can be a bit janky too, with different lookups depending from where it was in GP they launched it
  • There is a maintenance overhead with any code developed

For the above reasons it seemed like a good idea to wrap the native lookups in a .NET class, and not reinvent the wheel each time we need a lookup for a field we’ve not encountered before.  We have very, very many add in forms in .NET. Most of these forms involve selecting information from GP, examples such as  Sites/Debtors/Creditors/Item Numbers/Bin numbers etc. A few of those .NET forms are modal in nature, from David’s comments on this post I think it is time to review those forms and see if we can remove the modality.

Steve Endow kindly tweeted the way he tackles this. Perhaps I need to use GP lookups where it makes sense and develop an advanced search window of our own that is more generic and make certain that if that alternative window is used, that it adds value to the places where it is used vs the native lookups.

Windows 10 Technical Preview, Installing “media driver your computer needs is missing”

I had the above error installing windows 10 technical preview and hope my experience may help someone else.

I downloaded the preview ISO image from MSDN subscriber downloads. I attempted to burn the image to DVD using Nero burner. Nero said the ISO had unexpected length, do I want to fix it? I should have stopped at that point and investigated, but being on my way out the door, I left it to burn anyway.

A couple of days later I slapped a new SSD into my machine. Then booting from the DVD of the technical preview installer, I get the error shown below;

Windows 8 "A media driver your computer needs is missing" error

A media driver your computer needs is missing. This could be a DVD, USB or Hard disk driver. If you have a CD, DVD,  or USB flash drive with the driver on it, please insert it now.

Note: If the installation media for Windows is in the DVD drive or on a USB drive, you can safely remove it for this step.

This reminds me that the motherboard is 4 years old, so I go update the BIOS and SATA drivers on the existing windows and on the motherboard as it needs doing anyway. Half an hour later I’m back to the same issue, the above message when I try to run the installer. It is then I remember the message message from a couple of days previously, that I’d pushed to the back of my mind and forgotten. That message burning the image gave me an uneasy feeling, so to be certain I got the image downloaded again and checked it against the checksum on the download page, it passed. This time burning the fresh ISO raised no issues in Nero.

This time the Windows 10 install went though like lightening, with me up and running in no time.

Lessons learned

The CRC checksum provided on the download pages are worth using as downloads are not always perfect, and even a corrupt ISO will run in a fashion, making it unobvious there is an issue.