Author: NavNab (Page 2 of 2)

How to: Set Up Multiple Web Server Instances for the Microsoft Dynamics NAV Web Client – Part 2

If you enjoyed (or still enjoying?) creating your Web Clients manually like I described in one of my previous posts How to: Set Up Multiple Web Server Instances for the Microsoft Dynamics NAV Web Client โ€“ Part 1, so I believe it is time to automate this process a little bit.

To achieve that, I wrote a small PowerShell script. The script is self-explanatory ๐Ÿ˜‰

Feel free to use it, or better enhance it ๐Ÿ™‚

#Set-ExecutionPolicy RemoteSigned

mkdir ‘C:\Inetpub\wwwroot\MyWebClient’
mkdir ‘C:\ProgramData\Microsoft\Microsoft Dynamics NAV\90\Web Client\MyWebClient\WebClient\Resources\ExtractedResources’
cmd /c icacls ‘C:\ProgramData\Microsoft\Microsoft Dynamics NAV\90\Web Client\MyWebClient\WebClient\Resources\ExtractedResources’ /grant ‘IIS_IUSRS:(OI)(CI)(RX,W)’
copy ‘C:\Inetpub\wwwroot\\DynamicsNAV90\web.config’ ‘C:\Inetpub\wwwroot\MyWebClient\web.config’
Invoke-Expression -Command ‘cmd /c mklink /d “C:\Inetpub\wwwroot\MyWebClient\WebClient” “C:\Program Files\Microsoft Dynamics NAV\90\Web Client”‘

Import-Module WebAdministration
IIS:
New-WebVirtualDirectory -Site ‘Microsoft Dynamics NAV 2016 Web Client’ -Name ‘MyWebClient’ -PhysicalPath ‘C:\Inetpub\wwwroot\MyWebClient’
ConvertTo-WebApplication -PSPath ‘IIS:\Sites\Microsoft Dynamics NAV 2016 Web Client\MyWebClient\WebClient’ -ApplicationPool ‘Microsoft Dynamics NAV 2016 Web Client Application Pool’
New-Item ‘IIS:\Sites\Microsoft Dynamics NAV 2016 Web Client\MyWebClient\WebClient\Resources\ExtractedResources’ -type VirtualDirectory -physicalPath ‘C:\ProgramData\Microsoft\Microsoft Dynamics NAV\90\Web Client\MyWebClient\WebClient\Resources\ExtractedResources’

This blog is available also on Microsoft Dynamics NAV Community

How to list “ProcessOnly” Reports in Dynamics NAV 2009

I was doing my “daily NAV tour” on Mibuso and NAV Community forums when I spotted the following question:

I have about 300 new reports in my nav database and I need to write down the names of only those that are not ProcessingOnly. Do you know any smart way how to do this quick?

A member suggested an answer. But it applies to NAV new versions only (2015 and later). I could not resist the challenge. Hence my blog post to suggest a solution that applies for all old NAV versions (all versions might be a big word because I tested the code in a 2009 R2 database only ๐Ÿ˜‰ )

Letโ€™s get straight to the point. Here are the variables I used:

NameDataTypeSubtypeLength
TempObjectRecordAllObj 
AllObjRecordAllObj 
ObjectMetadataRecordObject Metadata 
XMLDocumentAutomation‘Microsoft XML, v6.0’.DOMDocument60 
InStrInStream  
TempFileFile  
TempFileNameText 250
TempStringText 1024

And the code:

ObjectMetadata.SETRANGE(“Object Type”, ObjectMetadata.”Object Type”::Report);
// Filter On report ID if needed
// ObjectMetadata.SETFILTER(“Object ID”, ‘MyFilter’);
IF ObjectMetadata.FINDSET THEN
REPEAT
ObjectMetadata.CALCFIELDS(Metadata);
IF ObjectMetadata.Metadata.HASVALUE THEN BEGIN
TempFileName := DELCHR(TEMPORARYPATH + FORMAT(CREATEGUID) + ‘.xml’, ‘=’, ‘{}-‘);

TempFile.CREATE(TempFileName);
TempFile.WRITEMODE := TRUE;
TempFile.TEXTMODE := TRUE;

ObjectMetadata.Metadata.CREATEINSTREAM(InStr);
InStr.READTEXT(TempString, 1024);
WHILE NOT InStr.EOS DO BEGIN
CLEAR(TempString);
InStr.READTEXT(TempString, 1024);
TempFile.WRITE(TempString);
END;

TempFile.CLOSE;

IF ISCLEAR(XMLDocument) THEN
CREATE(XMLDocument);

XMLDocument.load(TempFileName);
FILE.ERASE(TempFileName);

// 1 is ProcessOnly, 0 Others
IF XMLDocument.selectSingleNode(‘Report/ProcessingOnly’).text = ‘0’ THEN BEGIN
AllObj.GET(ObjectMetadata.”Object Type”, ObjectMetadata.”Object ID”);

TempObject.INIT;
TempObject.TRANSFERFIELDS(AllObj);
TempObject.INSERT;
END;
END;
UNTIL ObjectMetadata.NEXT = 0;

FORM.RUNMODAL(FORM::”All Objects”, TempObject);

And of course, the code adapted for NAV new versions (NAV 2016 in my test) ๐Ÿ˜‰

NameDataTypeSubtype
TempObjectRecordAllObj
AllObjRecordAllObj
TempBlobRecordTempBlob
ObjectMetadataRecordObject Metadata
XMLDOMManagementCodeunitXML DOM Management
XmlDocumentDotNetSystem.Xml.XmlDocument.’System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089′

ObjectMetadata.SETRANGE(“Object Type”, ObjectMetadata.”Object Type”::Report);
// ObjectMetadata.SETFILTER(“Object ID”, ‘3’);
IF ObjectMetadata.FINDSET THEN
REPEAT
ObjectMetadata.CALCFIELDS(Metadata);
IF ObjectMetadata.Metadata.HASVALUE THEN BEGIN
TempBlob.Blob := ObjectMetadata.Metadata;
XMLDOMManagement.LoadXMLDocumentFromText(TempBlob.ReadAsText(”, TEXTENCODING::UTF8), XmlDocument);

IF XMLDOMManagement.FindNodeText(XmlDocument, ‘Report/ProcessingOnly’) = ‘0’ THEN BEGIN
AllObj.GET(ObjectMetadata.”Object Type”, ObjectMetadata.”Object ID”);

TempObject.INIT;
TempObject.TRANSFERFIELDS(AllObj);
TempObject.INSERT;
END;
END;
UNTIL ObjectMetadata.NEXT = 0;

PAGE.RUNMODAL(PAGE::”All Objects”, TempObject);

This blog is available also on Microsoft Dynamics NAV Community

Dynamics NAV Web Client: Filters & FlowFilters on pages

As we all know, Microsoft stated that “Using Limit totals to is not supported. Use Filter on column instead” in Feature Limitations of the Microsoft Dynamics NAV Web Client.

We also know that accountant massively uses this functionality, among others. One of my customers said to me: I like the new web client, but I missed my flowfilters.

Such a waste! RIP CTRL+F7 & SHIFT+F7 :'(

TableFilters

If you also missed those two lovely buttons from Dynamics NAV 2009 (Classic Client) and older versions… Well, today we will resurrect them.

Today, I’ll show you how to combine those two powerful functions into one tiny powerful function (just like Goku and Vegeta’s fusion ๐Ÿ˜› ; don’t mind if you don’t know Dragon Ball).

Enough bla bla bla. The new “Table Filters” looks like this in the Web Client. It also works on Windows Client:

TableFilters_Resurrection

The trick consists of a simple action “TableFilters” you can add to every page on your database. You do not need to modify or adapt the code to fit other pages based on different tables.

Here is the complete code:

TableFilters_code

Do not worry, I will not let you write the code again and try to guess the variable types ๐Ÿ˜‰

Here is the Page 16 as an example tablefilter. I also included the code for NAV 2013 as it needed some rework.

Of course, I’ll let you enhance my “Table Filter” ๐Ÿ˜‰

Hey Microsoft, could you include this (or something like this) in all pages for new NAV versions?

This blog is available also on Microsoft Dynamics NAV Community

How to: Set Up Multiple Web Server Instances for the Microsoft Dynamics NAV Web Client – Part 1

No, you guessed wrong! I am not going to add another blog to explain how to use Powershell to create and setup a Dynamics NAV Web Instance.

As a quick reminder you can refer to msdn here and use Microsoft Dynamics NAV Administration Shell to easily create a new web instance.

But what if I cannot useย Microsoft Dynamics NAV Administration Shell? Yes, now you guessed right. This is the reason behind this blog post.

Scenario (summary in three points):

  • You installed NAV Server and Web Server on separate machines.
  • In your NAV Server you can locateย Microsoft Dynamics NAV Administration Shell.
  • In your Web Server you cannot locate Microsoft Dynamics NAV Administration Shell.

You quickly notice that you cannot apply what msdn says, because simply you do not have Microsoft Dynamics NAV Administration Shell installed on your Web Server.

What is the solution then? From my side, I explored two options:

  1. Powershell remote session from NAV Server to Web Server and apply the New-NAVWebServerInstance,
  2. Build a Web Instance from scratch.

I quickly dropped the first option due to network and firewall issues and because the second option sounds more fun ๐Ÿ˜‰

So, let’s build that web instance.

To achieve that, open your IIS and locate the default Web Instance, “DynamicsNAV90” in my case.

iis_web_client

It is easy now. You just must create the same structure (I highlighted the important parts).

  • Create a virtual directory,
  • Give it a name: MyWebClient
  • Point the physical path to a folder: “C:\inetpub\wwwroot\MyWebClient”
virtual_directory

Now, execute this command line as administrator:

mklink /d “C:\Inetpub\wwwroot\MyWebClient\WebClient” “C:\Program Files\Microsoft Dynamics NAV\90\Web Client”

This will create a symbolic link to the “C:\Inetpub\wwwroot\MyWebClient\WebClient” that points to “C:\Program Files\Microsoft Dynamics NAV\90\Web Client”.

Then, copy the “web.config” from the default web instance and past it to MyWebClient (Change the web.config to point to another NAV Server if needed):

webconfig

Now, create the following folder “C:\ProgramData\Microsoft\Microsoft Dynamics NAV\90\Web Client\MyWebClient\WebClient\Resources\ExtractedResources” and assign the following permissions to IIS_IUSRS:

ExtractedResorces

Create a Virtual Directory that points to the folder we just created:

ExtractedResorces_virtualdirectory

Last step, convert “WebClient” to an application:

application

Now, try to connect to your new and freshly created web site http://localhost:8080/MyWebClient/WebClient/

P.S1: in this blog, I used NAV 2016 as an example. But the same apply to all NAV versions with a web client.

P.S2: I used default installation folder. You may need to adapt this for your test.

P.S3: You try this trick on your own risk.

P.S4: I’ll let you play with it and create the whole web site from scratch ๐Ÿ˜‰

This blog is available also on Microsoft Dynamics NAV Community

Dynamics NAV Generic SOAP Client

Last summer, when I posted my first article I though blogging is very easy, and I’ll post an article every week. Actually, it’s not that easy. Anyway, after few months here is the article, I promised: a 100% generic web service client for NAV.

I was looking for a way to automate all my web service calls without managing, deploying, and struggling with all Dlls generated by Visual Studio. I was hoping to use CU 1290 “SOAP Web Service Request Mgt.” like described here. I quickly noticed that it is not working if the web service comes from another NAV Database (due to SOAP version used natively by NAV). So, I started looking around how Visual Studio generates Dlls I was used to use. I found the answer in this wonderful article from msdn.

This introduction begins to be longer than expected. So, let’s get into the bare bones of the topic.

As you guessed, I tried to translate the msdn article using .NET interoperability in NAV. The result was astonishing. I let you admire the similarities:

pure-c
Pure C#
pure-cal
Pure C/AL

The C/AL code remembers me this great article. My first reaction was: What the he**, I’m writing code like the great Vjekoslav Babiฤ‡.

Now, let me explain how it works. The CU uses four functions:

  1. InitClient: compiles the WSDL on the fly and prepares a ready to use client (proxy, dll… or whatever you want to call it) in memory.
  2. InitCallMethod: prepares the method to call with its parameters.
  3. CallMethod: invokes the method and retrieves the web service result.
  4. GetObjectValue: use the web service result in whatever way you want (result may be simple Text,Decimal… or complex Customer Record…).

Here is an example:

how-to-use

and this is the result:

example1

Enough talking, you can download the code here gws-with-examples.

Some readers may say:

But this needs to compile the client every time; this is huge for the memory.

This is true. The answer will be the subject of one of my next posts.

This blog is available also on Microsoft Dynamics NAV Community

My first blog post… about NAV

It’s been a few years now that I’m reading every single blog post about Dynamics NAV. I learned a lot from all the experts that they share their time with us. Thanks to them, I found answers to a lot of problems I faced in my professional life. Better, I learned enough to overcome challenges on my own.

Lately, I was thinking why not start blogging? So here I am, this is my first blog post. For sure, it is not directly about NAV as I said in the subject; and it will not give you any tip or trick as you expected.

But hey, wait for my next blog post. I already have an idea about its topic… It is about a 100% generic web service client for NAV.

This blog is available also on Microsoft Dynamics NAV Community
Newer posts »

© 2023 NAV NAB BLOG

Theme by Anders NorenUp ↑