NAS Failes to initialize with error “‘Já’ is not an option.”

Just got a request from a client because the Job Queue NAS is not working.  Stopped working after a service restart.  Looking through Event Viewer I see the following error.

In the %APPDATA% folder for the service user I find a file called NaviBP.xml.  This file includes a list of breakpoints from the last debugging session.  It seems that the debugger writes this file and uses the Icelandic ‘Já’ instead of the required English ‘Yes’.

After changing the <Enabled>Já</Enabled> to <Enabled>Yes</Enabled> the NAS should start normally.  If those breakpoints are no longer needed it is fine to just remove the file.

 

Client Temporary Path

In one of my solutions I create a lot of Excel and PDF documents.  All these documents are stored in BLOB fields and then downloaded to the client computer temporary folder and opened for the user.

Every time I use the ClientTempFileName function in Codeunit 419 a file is being created in the client computer temporary folder and that file is not deleted until the Role Tailored Client is closed.

Since the user is creating temporary files his whole workday I decided that a single instance codeunit would be a better way to store information about the client and server temporary file paths.  I created codeunit 50060 and two functions; GetClientTempPath and GetServerTempPath.
[code htmlscript=”false”]OBJECT Codeunit 50060 Application Temp Path Mgt.
{
OBJECT-PROPERTIES
{
Date=27.03.12;
Time=16:11:00;
Modified=Yes;
Version List=Dynamics.is;
}
PROPERTIES
{
SingleInstance=Yes;
OnRun=BEGIN
END;

}
CODE
{
VAR
ThreeTierMgt@1200050000 : Codeunit 419;
ClientTempPath@1200050001 : Text[1024];
ServerTempPath@1200050002 : Text[1024];

PROCEDURE GetClientTempPath@1200050000() : Text[1024];
BEGIN
IF ClientTempPath = ” THEN
ClientTempPath := ThreeTierMgt.Path(ThreeTierMgt.ClientTempFileName(”,”));
EXIT(ClientTempPath);
END;

PROCEDURE GetServerTempPath@1200050001() : Text[1024];
BEGIN
IF ServerTempPath = ” THEN
ServerTempPath := ThreeTierMgt.Path(ThreeTierMgt.ServerTempFileName(”,”));
EXIT(ServerTempPath);
END;

BEGIN
END.
}
}[/code]
The Source is here, Application Temporary Path

 

Automatic EMail from Change Log

I have been asked for a solution that can send an email when a customer is changed.  I have a few objects created and a codeunit that is executed by the Job Queue or manually from a page or a form.  First the Change Log needed to be activated.

Then after installing the attached object and adding page or from 77170 to the menu suite I can setup an email address for each table and each trigger.

Attached is the needed code, Change Log EMailer

Testing your Dynamics NAV Web Service

I am building a web service for one of my clients and another company is using this web service for an aspx web site.  I realized that I needed to test my web service before I can deliver it to that company.  So, I created a test codeunit for the job.

First I downloaded the universal XML import/export tool from Mibuso.  Then I added a function to the table 60000 XML Buffer that is in the above tool.
[code htmlscript=”false”]Read(VAR DOMDoc : Automation "’Microsoft XML, v6.0′.DOMDocument")
DELETEALL;
DOMNode := DOMDoc.documentElement;
Import2(DOMNode,1);
IF FINDFIRST THEN;[/code]
Next I create a read function in my test codeunit for every function in the web service.  Here is an example.
[code htmlscript=”false”]GetFarmerTankEntryAverageYW(FarmerID : Integer;MinYear : Integer;MaxYear : Integer;MinWeekNo : Integer;MaxWeekNo : Integer)
GetSetup;
CREATE(XMLDoc,TRUE,FALSE);

XMLProsInstr := XMLDoc.createProcessingInstruction(‘xml’,’version="1.0" encoding="utf-8"’);
XMLDoc.appendChild(XMLProsInstr);

CreateEnvelope(XMLElement1);
XMLElement2 := XMLDoc.createElement(‘soap:Body’);
XMLElement3 := XMLDoc.createElement(‘GetFarmerTankEntryAverageYW’);
XMLElement3.setAttribute(‘xmlns’,’urn:microsoft-dynamics-schemas/codeunit/RMWeb’);
CreateElement(XMLElement3, ‘farmerID’, FORMAT(FarmerID,0,9), ”, ”);
CreateElement(XMLElement3, ‘minYear’, FORMAT(MinYear,0,9), ”, ”);
CreateElement(XMLElement3, ‘maxYear’, FORMAT(MaxYear,0,9), ”, ”);
CreateElement(XMLElement3, ‘minWeekNo’, FORMAT(MinWeekNo,0,9), ”, ”);
CreateElement(XMLElement3, ‘maxWeekNo’, FORMAT(MaxWeekNo,0,9), ”, ”);
CreateElement(XMLElement3, ‘tankEntryXML’, ”, ”, ”);
XMLElement2.appendChild(XMLElement3);
XMLElement1.appendChild(XMLElement2);
XMLDoc.appendChild(XMLElement1);

WinHTTP.open(‘POST’,ServiceURL,FALSE,UserName,Password);
WinHTTP.setRequestHeader(‘Content-Type’,’text/xml; charset=utf-8′);
WinHTTP.setRequestHeader(‘SOAPAction’,’GetFarmerTankEntryAverageYW’);
WinHTTP.send(XMLDoc);

IF WinHTTP.status <> 200 THEN
ERROR(Text003,WinHTTP.status,WinHTTP.statusText);

XMLResponseDoc.load(WinHTTP.responseXML);
DisplayDocument(XMLResponseDoc);[/code]
This will use the XML Buffer to read the response document and display the result.  The Text Constant Text003 contains
[code htmlscript=”false”]ENU=Status error %1 %2;ISL=Stöðuvilla %1 %2[/code]
and the four functions used here contain
[code htmlscript=”false”]DisplayDocument(VAR XMLDoc : Automation "’Microsoft XML, v6.0′.DOMDocument")
XMLBuffer.Read(XMLDoc);
COMMIT;
FORM.RUNMODAL(FORM::"XML Buffer");

CreateEnvelope(VAR InElement : Automation "’Microsoft XML, v6.0′.IXMLDOMElement")
InElement := XMLRequestDoc.createElement(‘soap:Envelope’);
InElement.setAttribute(‘xmlns:soap’,’http://schemas.xmlsoap.org/soap/envelope/’);
InElement.setAttribute(‘xmlns:xsi’,’http://www.w3.org/2001/XMLSchema-instance’);
InElement.setAttribute(‘xmlns:xsd’,’http://www.w3.org/2001/XMLSchema’);

CreateElement(VAR InElement : Automation "’Microsoft XML, v6.0′.IXMLDOMElement";InNodeName : Text[50];InNodeValue : Text[250];InAttribu
TempElement := XMLRequestDoc.createElement(InNodeName);
TempElement.nodeTypedValue(InNodeValue);
IF InAttributeName <> ” THEN
TempElement.setAttribute(InAttributeName,InAttributeValue);
InElement.appendChild(TempElement);

GetSetup()
ServiceURL := ‘http://gunnar.dynamics.is:7047/DynamicsNAV/WS/CRONUS/Codeunit/WebService’;
UserName := ‘<Domain\User>’;
Password := ‘<Password>’;
IF ISCLEAR(WinHTTP) THEN
CREATE(WinHTTP,TRUE,FALSE);
IF ISCLEAR(XMLResponseDoc) THEN
CREATE(XMLResponseDoc,TRUE,FALSE);[/code]

Data Visualization Control not found

Just created a chart for a customer and added it to the customized role center.  The customer got a permission error when opening the client as there is no permission to read the table Chart no. 2000000078.  Added read permission to that table to the user role and the client started.  The next error was that the data visualization control was missing on the client machine.

A quick search pointed me to this download link.  After installing and restarting the client everything is working as it should be.

Ommit Zero in Calculation Formula

There are a few calculation methods available in for a flowfield.  This is a great feature in NAV to aggregate amounts from ledger entries.  I would like Microsoft to add an option to the flowfield declaration.  I would like to be able to omit zeros when using methods; Average, Exist, Count, Max and Min.  In a normal SQL it is possible to use NULL to archive this result but not in NAV.

The solution that I am using now is to create a boolean field for each of the amount fields that indicate if the amount is zero.  Then I have to add that boolean field to the sum-index enabled key and filter on that field.

Microsoft, please add this option to your upcoming releases of Dynamics NAV.  You can vote for this here.