Dynamics NAV 2017 Events

Dynamics NAV 2017 extensions

Well, I’m gonna try to explain some things about extensions and events in Dynamics NAV

First of all, forget your previous assumptions on how do you need to develop anything in NAV, forget to change tables, pages, codeunits. The new development paradigm resides in “create everything new and attach those new things to events”.

Yes, you need to use (purchase) objects.

What we are going to achieve with this new approach? A more stable Dynamics NAV, less problems with developments, an easy upgrade path and maybe, just maybe, some repeatability in the code deployments (this always depends on customer´s ability to understand a standard process).

There is no better way to learn than with a real example.

This is the scenario, in Mexico (with all its stupid’s laws) you need to withhold taxes from certain types of vendors usually called professional services, lease or freights.

This withholding has different types and percentages, for example, if the vendor is a person who gives you a receipt of fees for his work you need to make the next operations

Amount (+) 1000
VAT 16% (+) 160
VAT Withholding 2/3 of VAT (-) 10.67 106.67
Income Tax Withholding (-) 10% 100
Total Amount 953.33

Besides the calculation, you need to store the withholdings in a specific G/L account

Remember you cannot modify the standard tables, pages or codeunits on NAV!!!

My approach is:

Create a table called Withholding Groups

001

Create a “alternate” G/L Account table and in the new table, add some fields to the G/L Account

002

It’s very important to keep G/L Account and the new G/L Account copy synchronized

To achieve this first create a new codeunit (I called eAccSubscribers).

Create a new function called OnGLAccInsert (I used this kind of names to allow a very easy understanding).

003

Once created, click in the Properties button in the menú

004

Local must be No

Event – select Subscriber

EventPublisherObject – I use table 15, btw you can type “t 15” and NAV complete the field when you change to the next field

Event Function – choose OnAfterInsertEvent from the list

005

As you see, you have triggers or events for some actions or processes in NAV

In the next window asking for confirmation click ok.

Now let’s write some code, the subscriber has 2 parameters added by NAV, a Rec and a Boolean, the rec is related to the G/L account table so I´ve added a new variable to my G/L Account table called eAccGL.

The code is

eAccGL.”No.” := Rec.”No.”;

eAccGL.INSERT(TRUE)

What are we do to this moment? When a new G/L Account is inserted in the NAV Table 15, the code takes the t15.”No.” value and inserts the same data in the new table.

Now, you need to create another subscriber to complete the G/L Account information so we create a new function called OnGLAccModify with the next properties

006

Nav adds these parameters

007

We can use a TRANSFERFIELDS but I don’t need all G/L Account fields, just some, so I need to write every field one by one

008

and so on.

You can create an On Delete function.

Now save the codeunit and create a new G/L Account, then run the copied table and you´ll see the added account.

Now, you need to setup the G/L accounts and the withholding groups before start the tricky part, insert new lines before post execution code.

In previous versions you can create a codeunit to check if the G/L account needs to be withholded, and create the new lines in purchase line table and finally, you have some choices, create a button in the menu to call the create lines function (Page modification), add this behavior in the Release button (Codeunit Modification) or modify codeunit 90 (again codeunit modification).

Now we can create the same codeunit to check G/L Account, create lines, etc), but in this version we create a subscriber called CheckIFWHGLAccOnPost, the eventpublisherobject is the codeunit 90 and the event is OnBeforePostPurchaseDoc

009

Add some code to make all calculations and line insertions like this

010

Finally, test the function

Create Purchase Invoice and select the account with withholding

011

Post and check the lines

012

 

Anuncios

About the cloud

Along time ago (nov 2011) I wrote a 5 parts blog post about the cloud, now reading that again, I can’t find something to change my point of view. Cloud is a very expensive way of work, maybe because the cloud is not my computer, is another guy computer.

A few months ago, one of the projects is going to go live and the customer´s technical leader and I made a technical design for the new deployment. We´re talking about 70 -75 concurrent users with at least 5 remote offices, 15 companies with purchase, warehouse, assembly, sales and financial transactions. We are going to deploy Dynamics NAV 2015 with SQL 2014.

Somebody talks something about the “cloud” and everything goes to a new level, a “cloud & azure” partner comes to the scene. It was very funny to see what followed.

That partner sends their “deployment” proposal:

  • AD Server on Azure A2 3.5 GB RAM
  • 1 NAV server on Azure A3 7 GB RAM
  • 1 SQL server on Azure A4 14 GB RAM

They talked about VPNs from physical sites to servers, 20×100,000 storage transactions and 500 GB for data transfer

We laugh a lot and we commented that if he could make a little more realistic scenario.

After that he send a new proposal:

  • AD Server on Azure A2 3.5 GB RAM
  • 1 NAV server on Azure A4 14 GB RAM
  • 1 SQL server on Azure D4 28 GB RAM

As you can see, the proposal only changes a little. Next he sends the third version:

  • AD Server on Azure A2 3.5 GB RAM
  • 1 NAV server on Azure A4 14 GB RAM
  • 1 SQL server on Azure D3 28 GB RAM

And they talked about a growth of 30 users in 2 years (we have 70 users license so we going to have 70 users in the go live, not in 2 years).

When we talked with the partner about our concerns, they say, “everything is going to run fast because we are going to us the NAV server as Remote Desktop Server to give the users the best experience”. More and more laughs. I asked them about the printing problem, the delay when you print, the problem with the UPD of windows server, they had an answer “don’t worry, we can use citrix”, the customer responds “and who is gonna pay for the citrix licenses?”. An awkward silence on the line.

Finally, the customer says thanks and throw the papers in the trash can.

What we finally install??

  • A Dell Server with 256 GB RAM
  • 6 Virtual servers with Hyper V
  • AD Server, electronic invoicing.
  • 1 SQL server with 64 GB RAM and 8 Cores
  • 2 NAV server with 64 GB RAM and 2 cores each (runs LAN instances with windows auth and certificate auth for external access).
  • The SQL has 4 partitions (OS, SQL, Datafile, logfile) all in SSD.
  • 1 backup server with SQL and NAV
  • And in an old physical server a secondary domain controller with a copy of the SQL for backup too.

The server cost was around the half of the azure investment for 2 years and the sizing was designed for 5 years.

There is no complains of slowness by the users.

We have access to NAV with certificates and now we can run in NAV Client, Web Client and Tablet Client.

There are no printing problems (we only use terminal server to manage the servers).

I scheduled a daily maintenance in the SQL server.

What we can learn from this?

  1. Look for a partner who has real experience deploying Dynamics NAV. Not all the azure and cloud partners has the experience or the knowledge to make this well.
  2. Remember and always remember, talking about NAV, SQL and memory, more and bigger it´s better.
  3. Like with the doctor, always look for a second opinion.
  4. Read the small letters (storage transactions ans data transfer).
  5. Learn about new Dynamics NAV technologies (Certificates, webclient, phone client).

Dynamics NAV requirements

Well, Microsoft always give the hardware requirements for the systems they sol, but everybody knows that those specs are to low, maybe they need to put in those documents “to crawl” instead “to run”.

In my experience, talking about 3 tier setup with up to 30 users, you will need for SQL server at least 64 GB RAM, I’m taking in to account snapshots, maintenance, reindexing, update statistics. the NAV server (running 2 instances, LAN/domain instance and remote with certificates instance) needs at least 32 GB of RAM and finally, the client needs at least 4 GB of RAM if you just use word, excel and outlook besides NAV client (Preferably 8).

For 2 tier setup (one server running SQL and NAV with the client running in the cliente computer) you need at least 64 GB of RAM for 30 users.

Remember , Dynamics NAV needs a lots of RAM, you can use 2.2 processors (preferably 2 procs per server) with 2 cores minimum.

The best HDD is SSD, if its to expensive, you can use SATA disks but always in RAID 10 (never use RAID 5, its very slow), you need 4 disks minimum.

Another important thing is the bandwidth, for 30 users maybe 10 Mbps for the NAV server and between NAV and SQL servers a 100 Mbps or 1 GB direct connection.

You can always enhance your NAV experience adding more memory and using less flowfields ;-).

Dynamics NAV 2016 After installation problems

Well, I had thought that everything was ok but I found my first problem.

Microsoft its going to say “normal clients don’t use that setup configuration” but its normal in my world (and my laptop).

When I open my NAV2016 works ok, everything, but…. I need to open a NAV2015 DB, so, I had to change the db in the NAV instance and…..

image

I think, ups, I clicked the wrong shortcut so I did it again, sloooow this time and the same result, so I had checked the shortcut properties and the address was “C:\Program Files (x86)\Microsoft Dynamics NAV\80\RoleTailored Client\Microsoft Dynamics NAV Server.msc” but when I check the msc version I got this info.

image

So I had to modify my CustomSettings.config file manually to get my db online and work

I think is a registry thing but I can´t find the key

Well, got the first error

Dynamics NAV 2016 Setup

Ok, I recognize it, I can´t wait another day.

I’ve just installed Dynamics NAV 2016

Here are my screenshots (NA version in Spanish Mexico).

clip_image002

clip_image004

As usual I chose customized installation

clip_image006

clip_image008

clip_image010

Change my ports to support multiple NAV instances and versions

clip_image012

clip_image014

clip_image016

clip_image018

clip_image020

clip_image022

Just checking if everything its ok

clip_image024

clip_image026

clip_image028

Check my new menus

clip_image030

And new functions

clip_image032

clip_image034

clip_image036

BTW,  the small webpage is the new Phone Client

The url for the phone client is (in my computer, remember  I’ve changed the port) you just need phone.aspx instead tablet,aspx

http://localhost:8090/DynamicsNAV90/WebClient/phone.aspx

image

Problems with Windows 10 Continue

Well it seems that installing just Dynamics NAV 2015 (alone) Works fine but….

When I install Dynamics NAV 2013 R2 the spn error arise again broken my previus 2015 install.

I try to use another user to make the things work but I cant.

I’m thinking there is a problema with security when the systems try to add or register new spn’s for the services, you know add spn for localhost:port for the service.

I cant find where I can add the logon as a service for the administrator account, when I try to list the registered spn’s the OS told me that it cant found the computer\user account; when I try to register manually the spn throws the same error.

I you only use ONE Dynamics NAV versión, you can follow the previous post; but if you need to have more versions (in my case , NAV 5.0, 2009, 2013, 2013R2 and 2015, all running together), its better to wait till Microsoft give us a fix to this problema

In this moment i’m installing Windows Server 2012 R2, a more stable OS for my needs

Windows 10 Upgrade and Dynamics NAV problems

Ok I make the upgrade to Windows 10 from Windows 8.1 and #BigFAIL so I need to move all my data, documents and everything to another computer (Thanks Microsoft, I really appreciate all this job in my weekend).

So I need to think what I’m going to do, reinstall windows 8.1? install Windows 2012? (my preferred system but in my work exists some software policies)or try to give a chance to the new OS?

Searching in Internet found the Totovic blog, http://totovic.com/2015/07/29/which-nav-versions-can-run-on-windows-10/ and a link to NAV MVP Erik Hougaard who wrote http://www.hougaard.com/microsoft-dynamics-nav-and-windows-10/ and think:

Why he can run nav and I cant?

first of all, I post in Totovic blog that every broke (really kaput) but in another post I wrote about the upgrade, maybe from scratch can work so

Just installed Windows 10 from scratch, yes you can removing all data, configuration and all system (thanks to msft i’ve moved all my data to another computer).

After install I need to actívate Administrator account using Net User /active: yes in command line (thats because I always use admin for work, its my laptop).
Install SQL Server 2014 mixed mode

sql
Install NAV then error in web server components
Install NAV without webserver components

NAV cant start with network service account, change to administrator account
NAV starts ok
Try to add webserver components and help
the setup throws error 1603 because the IIS URL rewrite Module ask for IIS 7.0 or higher (Windows 10 shows iis 10)
Modify the rewrite_2.0_rtw_x64.msi package with orca to avoid the iis versión validation in the LaunchCodition (the images shows after remove the line)

orca
start Dynamics NAV installation again and add the web components and Help

webserver components

Finally check all

Web client

webclient

webclient1

Tablet Client

webclientTablet

Now, let try with NAV 2013 R2

Dynamics NAV 2013 Stylesheets

Suponiendo que saben la operación básica de las stylesheets en NAV (como se hacen y para que sirven).

Para hacer funcionar las Stylesheets en NAV 2013 se debe importar los objetos correspondientes desde Partner Source o Mibuso.

Una vez importados y compilados, ejecutamos la pagina de Setup y configuramos los datos necesarios.

Se crea el stylesheet eligiendo la o las tablas y campos necesarios, se crea el mail merge y el stylesheet.

Finalmente, en la pagina donde se ejecutara el stylesheet creado se modifica creando una nueva acción de la pagina donde el Action debe ser <Action680> y el caption debe ser Style Sheets.

Después en el trigger OnAction, se agrega el siguiente código en una sola línea (aquí se ve así porque lo parte por el formato de la pagina).

StyleSheetDataMgt.LoadStylesheetDataRTC(GETPOSITION,CURRENTKEY,PAGE::””);

image

Donde StyleSheetDataMgt es una variable tipo codeunit referenciada a la codeunit 682 (Style Sheet Data Management) .

En PAGE::”AQUI SE PONE EL NUMERO DE LA PAGINA DONDE SE EJECUTARA EL STYLESHEET”

image

Dynamics NAV 2013 R2 Help Server

En NAV 2013 R2 se creó el nuevo Help Server.

Este es un servidor web de ayuda para la aplicación con lo que nos evitamos de estar haciendo la ayuda en archivos chm.

Ahora podemos editar con ayuda de un editor web toda las páginas como muestro en la siguiente imagen (si, es Expression Web de Microsoft, no me gusta el dw).

image

Simplemente abrimos la pagina web que queremos modificar en el editor, la modificamos y la guardamos y con eso aparecerán los cambios en el sitio (para modificar debemos de ajustar los permisos en el archivo service.lck que esta en x:\inetpub\wwwroot\_vti_pvt\

Los archivos se encuentran en la ruta x:\inetpub\wwwroot\DynamicsNAV71Help\help\

Ahora bien, se genera una nueva funcionalidad en NAV que no esta basada en las tablas del sistema, ¿como la mostramos en la ayuda?

Haciendo uso de la forma de trabajo, “toma algo que ya esta y reusalo”, simplemente copiamos una página existente del directorio de help mencionado y lo salvamos con el numero de la nueva tabla por ejemplo T_50000.

image

La abrimos en el Expression Web y la modificamos y salvamos en la ruta de help.

image

Abrimos la pagina que tiene como base la tabla 50000 y listo, aparecerá la ayuda sobre la nueva tabla.

image

Dynamics NAV2013 R2 Copiar Empresa

Para copiar una empresa a una nueva dentro del mismo Tenant se deberá entrar al PowerShell y conectar los cmdlets de NAV

image

Una vez hecho lo anterior en el panel lateral Derecho damos clic en Actualizar y después escribimos Copy

image

Llenamos los campos requeridos para la tarea

image

Terminada esta parte le damos clic en Copiar y pegamos en el área de scripts de la parte superior

image

Damos clic en el botón ejecutar con lo que aparecerá la siguiente ventana

image

Damos clic en aceptar y esperamos que termine de ejecutar el script

image

Al terminar sin errores verificamos en la parte inferior en la barra de estado

image

Abrimos NAV y verificamos la nueva compañía

image

image

Ahora tendremos una empresa ya lista para probar las configuraciones.