NAS problem in Nav 3.1

I have installed NAS and configured. And in codeunit 1 i have put startup parameter ‘NAVISIONSERVICE’ for example which runs a codeunit. This codeunit contains code to insert some records in table. After the service startup i get an error in event viewer that says ‘No Application Setup is specified for NAVISIONSERVICE’. But when i give just a message to run like ‘hi from nas’, then it executes fine, but why it doesnt run the codeunit?

The code i placed in codeunit 1 under function NAShandler looks something like this…my code is in bold. It runs the message (‘hi from nas’) but doesnt run the codeunit My timer. it gives an error ‘No Application Setup is specified for NAVISIONSERVICE’, what must be the wrong?

CGStarted := FALSE;
ParamStr := NASID;
REPEAT
SepPosition := STRPOS(ParamStr,’,’);
IF SepPosition > 0 THEN
Parameter := COPYSTR(ParamStr,1,SepPosition - 1)
ELSE
Parameter := COPYSTR(ParamStr,1);
IF Parameter = ‘CG’ THEN BEGIN
BizTalkNASStartup.RUN;
CGStarted := TRUE;
END;

ParamStr := COPYSTR(ParamStr,SepPosition + 1);
UNTIL SepPosition = 0;

IF NOT CGStarted THEN BEGIN
IF Parameter=‘NAVISIONSERVICE’ THEN
//CODEUNIT.RUN(CODEUNIT::“My Timer”);
MESSAGE(‘hi from nas’);

NASMgt.SetNASID(NASID);
WORKDATE := 0D;

Use a form to call the the NAS Handler function and pass into the same parameter string you are passing to the service. Run the debugger and make sure your parameter string is getting parsed as expected.

If you get the message, then the codeunit should run as well. I would have to see the code itself to be able to help you troubleshoot it. The first thing I would check though is make sure that the codeunit is a single instance codeunit. Open the codeunit in design, open the properties page and make sure the ‘SingleInstance’ property is set to ‘Yes’. Then inside, make sure that the timer itself is enabled, has a timer interval, etcetera.

If you go to Codeunit 1, and go to the Globals and click on the Text Constants tab, and then search for that Text Constant in the code, you will find that it only gets executed if the Parameter is never parsed to equal ‘NAVISIONSERVICE’.

As I can see you had placed the code wrong.

Try following:

CGStarted := FALSE;
ParamStr := NASID;
REPEAT
SepPosition := STRPOS(ParamStr,’,’);
IF SepPosition > 0 THEN
Parameter := COPYSTR(ParamStr,1,SepPosition - 1)
ELSE
Parameter := COPYSTR(ParamStr,1);
IF Parameter = ‘CG’ THEN BEGIN
BizTalkNASStartup.RUN;
CGStarted := TRUE;
END;
IF Parameter=‘NAVISIONSERVICE’ THEN BEGIN
CODEUNIT.RUN(CODEUNIT::“My Timer”);
CGStarted := TRUE;
END;

ParamStr := COPYSTR(ParamStr,SepPosition + 1);
UNTIL SepPosition = 0;

IF NOT CGStarted THEN BEGIN
NASMgt.SetNASID(NASID);
WORKDATE := 0D;

Best Regards

Bjarne

Well as far as placement of custom startup parameters, I always put that in the CASE at the end of the NASHandler function.

CASE Parameter OF
//>> start custom parameters
’MYCUSTOMSTARTUPPARAMETER’:
BEGIN
// write your custom code here
END;
//<< end custom parameters
‘OSYNCH’,‘JOBQUEUE’:
BEGIN
IF NOT JobQueueSetup.GET THEN BEGIN
JobQueueSetup.INIT;
JobQueueSetup.INSERT;
END;
IF NOT JobQueueSetup.“Job Queue Active” THEN BEGIN
JobQueueSetup.VALIDATE(“Job Queue Active”,TRUE);
JobQueueSetup.MODIFY;
END;
CODEUNIT.RUN(CODEUNIT::“Job Queue Dispacher”);
END;
END;

The point is though, that apparently the value of the startup parameter DOES get evaluated, becuase he claims that he sees the message. So my conclusion is that the issue is not when the parameter is evaluated, but in the codeunit itself. One way to find out if it gets to the codeunit to begin with, is to put a message “the codeunit runs!!!” in the OnRun trigger of the codeunit. If you never see that message it is proof that the codeunit doesn’t run. If it does show up, then there are issues with the rest of the codeunit, like I said before.

Hi Daniel,

Your example is from NAV 5.0 and not Attain 3.10 where IMRAN have the problem.

The function NASMgt.SetNASID(NASID); have an error message if NASSetup was not found for NASID. The error message is ‘No Application Setup is specified for %1’ where %1 is NASID.

So whatever the codeunit ‘My Timer’ work or not the error message will stop the application server.

Best Regards

Bjarne

Thanks alot for every body. I will check the problem based on all your answers. Sorry for late reply.

I’m pretty sure the CASE statement has been in there since that version. Anyway it doesn’t really matter where the statement is.

His original problem was that his message appears in the event viewer, but his codeunit doesn’t seem to run. If he gets the message, but the codeunit doesn’t appear to run I don’t think it is about where the statement is, the issue is in the custom codeunit I think, not in codeunit 1. Here’s IMRAN’s code:

He says that he DOES see the message, but when he runs the codeunit nothing happens. He doesn’t say anything about an error from SetNASID. So my thought is that if he changes the code to this:

And the codeunit doesn’t appear to run, then the issue is in the codeunit itself. My first step would be to put a message in the OnRun trigger MESSAGE(‘The codeunit started successfully’), and take it from there. If it appears in the event viewer, you know that it gets to the codeunit. If it doesn’t then there’s another problem.

Personally I think either the codeunit is not set as single instance, or the timer object is not instantiated correctly.

You’re probably right about the source of the problem, Denster.

But when it comes to tracing through to functions and codeunits, isn’t that what the debugger is designed to do?

Debug! Don’t speculate!

This is a NAS issue, which are always tricky to debug. It would take me less time to put a little message in the codeunit for testing purposes than the time it would take to set up a proper debug scenario, so that’s why I would do that as a first step.

It’s a matter of personal preference – but creating a form, calling a function, and throwing a breakpoint in there seems pretty fast to me, and definitely more flexible. I don’t think you even have to save the form.

It looks as though you’re trying to convince me of something [:)]. There are many ways to accomplish certain tasks, does it really matter HOW you do things, as long as you get the results?

Nope, it doesn’t.

Hi Daniel,

The CASE statement came first in 3.70x. You can’t see any CASE statement in IMRAN code.

That really matter where you put the code because the function NASMgt.SetNASID(NASID) will raise an error. When there are an error in the NASHandler function the NAS will stop working.

The reason IMRAN get the message ‘hi from nas’ in event log is because the message is before the error in NASMgt.SetNASID(NASID)

The OnRun in ‘My Timer’ is running too. Now we don’t know the code in OnRun but I think it will start a timer. But again because NASMgt.SetNASID(NASID) raise an error the timer never get fired.

IMRAN wrote he insert some records in a table. If he do that in OnRun and don’t have a COMMIT so will the transaction be rollback because the error in NASMgt.SetNASID(NASID)

Best Regards

Bjarne

No I am still not convinced [:D] I looked at a 3.6 codeunit 1 (I have 2.6 and then 3.6, no 3.1) and there was indeed a “CASE Parameter OF” statement. Just because IMRAN didn’t paste the CASE in here doesn’t mean it is not there.

I would agree with you, but that error message would show up in the event log. If the SetNASID function had caused an error, this would have showed up in the event log as well. Given that IMRAN did not tell us about any error in the event log, I am assuming that there is in fact no error in the event log, which is an indication that this is not what caused the code not to run. Let’s ask IMRAN.

@ IMRAN: in addition to your custom message, is there an error in the event log that says '‘No Application Setup is specified for NAVISIONSERVICE’?

It was bugging me so I downloaded a 3.1 database and it does not have the CASE that I talked about. I would have to agree with Bjarne that the error might be what caused this to fail, and you should move the code to where he suggested. [Y]

Still I am confused that IMRAN did not tell us about that error though [:^)]