NAS and Job Queue Problem

Hello, Can you please help with a Job Queue problem in Nav 5.

I have set up the NAS according to instruction with a parameter of JOBQUEUE and a windows login which has a super user access.

When trying to run a codeunit such as g/l account-indent or a simple report we get the following error in the Job Queue Log Entry:

"The value of COPYSTR parameter 2 is outside of the permitted range.

The current value is: 0.
The permitted range is: from 1 to 2147483647."

Not sure if this is a red herring, but I have set a report to run AppMan.NASHandler(‘JOBQUEUE’); where AppMan is codeunit 1 and the debugger seems to error on the function HAsWinPermission in Codeunit 449

Found := UPPERCASE(COPYSTR(WinLogin.ID,STRLEN,STRLEN(Winlogin.ID) - STRLEN(UserId2))) = UPPERCASE(SUBSTRNO(’%1’,UserId2));

Winlogin is uninitialised.

I have not seen any other errors like this on the site so presume we have set something up incorrectly, but can anyone help as to what it may be?

Regards

Richard

Hi Richard,

I experienced that when trying to run a codeunit directly from the job queue, i had an error in the log, about the codeunit being called with job queue entry record as parameter… My codeunit didn’t call for that parameter…
But that error was caught by the error-log.

I believe the STRLEN i have highlighted will return 0, since u ask for the length of “nothing”.
(It shouldn’t be there, according to CU449 in my 5.0 DB)

Sorry Alexander, I typed the STRLEN in twice, the code is

Found := UPPERCASE(COPYSTR(WinLogin.ID,STRLEN(Winlogin.ID) - STRLEN(UserId2))) = UPPERCASE(SUBSTRNO(’%1’,UserId2));

That makes more sense…

Are You absolutely sure it is the correct database…
And not some stand-alone DB, without users…

This calculation is the one that results in the 0 = parameter 2 (from the error-message).
UserId2 is the user-id You see on the job queue entry card, and is same as the user that created the entry.
That value should be without any domain-reference if you use windows-authentication.
(e.g. if i log on using DOMAIN\USER, the value should be USER)
Values found in Winlogin.ID, always include the domain-reference, and therefore always (almost) have greater length than just the user-name.

So You have to check what You have in the Winlogin-table, and also what value is stored in the Job Queue Entry - User ID.

We have only the one database which I have specified in the NAS. We are using the native database. I will check again.

User on job queue entry card is smith.s as theycreated it. In windows login table id is Domain\smith.s. (the NAS user login is Domain\jones.s) both have super rights.

On my error the windows login table was not initialised so could that be part of the problem?

[:$] You mentioned that…

That could very well be part of the problem.

I’m not sure how it got inside the REPEAT - UNTIL, if the winlogin is uninitialised.
Maybe someone else can give some input on that.

if winlogin is not initialised, the i would expect STRLEN(winlogin.ID) to return 0.
STRLEN(UserID2) should return 7 if the userid on job queue entry card is smith.s.
But that would give -7 as parameter 2, and not 0 as the error says…

I agree with your last comment and suspect that the debugger information is not quite correct. I’ll look again at seeing if it is using the correct database, but the nas user is being shown as being logged in.

PS I was not able to use the snap-in as it failed to initialise (used regedit and services to put in the data). NAS is on the same server as the database server.

I am waiting for the solution centre to come out but not quick.

The way You have registered the NAS, and the different parameters should be just the same as using the snapin.

I belive there is an entry in the eventlog - application, where You can verify the servername, databasename, companyname and startupparameter.

You can also start the NAS in a command-prompt, then servername etc. will be shown there.
(that shows messages that otherwise would be written in the eventlog)

Also if the nas-user is shown as logged in, that is another indicator that the correct DB is used.
To verify that, open the sessions-window, verify that the nas-user is there… shut down the service, and verify that the nas-user is no longer there…
(maybe someone uses this login through an ordinary client)

Thanks, the user only appears when nas is running and is not a user anyone will know. Hace re-tried with administrator as the login and some event log messages are appearing - but just saying cannot give enough detail.

How do you start in the command prompt please?

Hi Richard,

Sure…

Navigate to the correct directory…

Command must be something like this…
nas appservername=NameOfYourService, servername=NameOfYourServer, company=NameOfYourCompany, startupparameter=JOBQUEUE
(this is descriped in the NAS-manual chapter 2, page 14 bottom)

Thanks for all your help Alexander, but just found the problem or part of it - and should have seen it earlier - if fact you refered you it!!

Our user id was longer than the windows login ID and therefore fell over when that happened.

Used a userid of 13 characters and failed on first record of the repeat login id also 13 characters. Used a userid of 11 characters and failed on 3rd record with a login 1d of 11 characters! The winlogin was ininitialised as it was exited when the error appeared.

Just now need solution centre to provide the code - we don’t have permission. At least I this was not a training issue.

Thanks

Will mark as solved once I know for certain

Richard,

What if the job queue entry is created by someone with an extremely short login-id?

btw…
You mentioned that You want to run a codeunit…
Remember to create it so that it calls for Job Queue Entry as parameter, or create a report to call the codeunit, and call the report from the job queue.
(hope it makes sence)

I have used the shortest ID we have and it works.

Did have a further problem with permissions in it seems you have to specifically give permission to each report/codeunit