Rashed Amini

The ara3n weblog

Archive for May, 2008

Monitoring User Errors in Navision

24th May 2008

I’m writing this blog in response to a request asking for a way to log all the errors users get in Navision.
Installing this on customer site will allow solution centers to see what kind of errors users are getting, and the client to prevent making the same mistakes and teach the user to do it the correct way.

You can write reports on most errors that has occurred.
See how often users get locking errors.
See what kind of errors developers are making during programming.
See what errors NAS is getting for ADCS.

This solution works with 5.x and higher.
If you have older version, you need to do an exe upgrade.

To manually start the monitor tools. Run CU “Error Listener”. To automatically start it Add to CU 1 the following code

CompanyOpen()
//Mod02 Start
CODEUNIT.RUN(CODEUNIT::"Error Listener");
//Mod02 End

Here is the Error Monitor Objects

Posted in Dynamics NAV | 1 Comment »

Access SQL 2005 Stored Procedure through WebServices

13th May 2008

SQL 2005 has added a new feature called ENDPOINT. You can use it to created a webservice on SQL server and access it from Navision.
You can create a stored procedure in and call it from Navision through webservice. this is another way to do it instead of ADO. You can use this to load long strings which can be done by XMLPort using BigText.

Here is how to create a stored procedure and creating webservice for it.


create procedure dbo.GetEmployees
As
select [No_], [First Name], [Last Name]
FROM [Navision-5].[dbo].[KRONUS5$Employee]
go

Here is how create a webservice for this stored procedure.


CREATE ENDPOINT GetEmployees
STATE = STARTED
AS HTTP
(
PATH = '/Employee',
AUTHENTICATION = (INTEGRATED),
PORTS = (CLEAR),
CLEAR_PORT = 8000,
SITE = 'localhost'
)
FOR SOAP
(
WEBMETHOD 'EmployeeList'
(NAME='Navision-5.dbo.GetEmployees'),
BATCHES = DISABLED,
WSDL = DEFAULT,
DATABASE = 'Navision-5',
NAMESPACE = 'http://Navision-5/Employee'
)
go

In example above i’ve defined port 8000. To access the webservice through IE. Use the following address.
http://localhost:8000/Employee?wsdl

Here is Navision code on how to access this webservice.

IF ISCLEAR(XmlDoc) THEN
CREATE(XmlDoc);

IF ISCLEAR(XmlHttp) THEN
CREATE(XmlHttp);

TempFileName := 'c:\tempxmlfile';
MyFile.CREATE(TempFileName);

MyFile.TEXTMODE(TRUE);
MyFile.WRITEMODE(TRUE);
MyFile.WRITE('');
MyFile.WRITE('');
MyFile.WRITE('');
MyFile.WRITE('');
MyFile.WRITE('');
MyFile.WRITE('');

MyFile.CLOSE;

XmlDoc.async := FALSE;
XmlDoc.load(TempFileName);

XmlHttp.Open('POST','http://localhost:8000/Employee',0);
XmlHttp.SetRequestHeader('Content-type','text/xml');
XmlHttp.SetRequestHeader('SOAPAction','"http://Navision-5/EmployeeEmployeeList"');
XmlHttp.SetTimeouts(10000,10000,10000,10000);

XmlHttp.Send(XmlDoc);

IF XmlHttp.Status 200 THEN
message('Http Error ' + ' ' + FORMAT(XmlHttp.Status) + ': ' + XmlHttp.StatusText);

XmlDoc.async := FALSE;
XmlDoc.load(XmlHttp.ResponseBody);

XmlDoc.save('C:\response.xml');
HYPERLINK('C:\response.xml');

CLEAR(XmlDoc);
CLEAR(XmlHttp)

Here is the SQL Form Example to the Form.

Posted in Dynamics NAV | No Comments »

Navision SQL 2005 Team Developement

12th May 2008

Navision Development has a weakness when working with a team of developers on same server. The problem is that developers can overwrite each other objects. This causes loss of work. There are many solution outside of Navision to solve this issue. The following tool, I’ve written for sql 2005. It uses .NET SQL CLR. This works only on sql 2005.

This tool automatically reserves the object the first time you save the object. Each developer needs to have a unique User ID in order for this tool to work. It works with windows and Database Authentication. I recommend to set your object cache to zero.
Download the Object Reservation. file.
Inside you’ll find the fob. Import the fob. Open SQL SMS and run the script provided in the PDF document.

After you install it in Navision, and try to save another object you’ll get the following error.

ReservationError

Basically this tool will multiple developers work in the same database without overwriting each other object.

Posted in Dynamics NAV | 7 Comments »