Auto startup Navision & Run Codeunit

rocopsarocopsa Member Posts: 38
edited 2012-12-20 in NAV Three Tier
Dear experts,

I am doing some data exchange addon with other system and this got to be executed in mid-night.

Since existing coding in Navision is necessary, I have to use codeunit inside Navision.

I am now using Windows Task Schedule to execute finsql.exe and using Codeunit #1 to automate the job. All runs fine as if I am logging in. BUT.... when finsql.exe is executed when Windows is NOT logging in, it seems Codeunit #1 is not being run and so, my codes are also not started.

Inside Task Schedule, I have added all the startup parameters like ntauthenatication, server, database, company. Yet, still in vain..... ](*,)

So, do you have any good idea on that? The key is, I have to use codeunit in Navision to finish my job.

Thanks in advance! [-o<
Rocopsa

Answers

  • Luc_VanDyckLuc_VanDyck Member, Moderator, Administrator Posts: 3,633
    Use the NAV Application Server, together with the Job Queue module, to schedule the execution of your codenit. The NAS runs as a Windows sevice and can be described as a NAV client without a user interface.
    No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)
  • rocopsarocopsa Member Posts: 38
    Dear Luc Van Dyck,

    Thanks very much! But, I am too fresh on NAS server and JobQueue, I failed to do so.

    The NAS server is succesfully "Started" by NASMSnapIn.msc and JobQueue card has been made, yet, it seems the Job is not executed at the assigned time (Earliest Start Datetime)..... ](*,)

    I have tried to look into many many posts there, but, cannot find the answer.....

    Do you have any idea on this?

    Thanks very much in advance!
    Rocopsa
  • rocopsarocopsa Member Posts: 38
    Oh! Finally, I correct the Startup parameter in NASMSnapIn into JOBQUEUE and those JobQ has been executed. Yet...... encounter error as "...It has no parameter".

    So, I will look for posts again for the solution. But, if you have any hints, please could you advise?

    Thanks in advance!
    Rocopsa
  • Luc_VanDyckLuc_VanDyck Member, Moderator, Administrator Posts: 3,633
    The codeunit that is going to be executed through the JobQueue needs to have a parameter. That parameter needs to be a "Job Queue Entry" record. See for example codeunit 5917 or 5918.
    No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)
  • rocopsarocopsa Member Posts: 38
    Thank you very much Luc Van Dyck.

    Since I am running out of time, I use Report in JOBQUEUE instead and inside the report, CODEUNIT.RUN(mycodeunit) to execute my codeunit.

    Nevertheless, the JOBQUEUE sucessfully executed BUT...., my codeunit is not being run. Neither my machine is logged on or not.

    So, I would like to ask is there any restriction inside the codeunit in JOBQUEUE? My codeunit is to export the whole Item master as a txt file to a specific path. It runs fine when I press the [RUN] button manually, txt files are created in the path. But NOT in JOBQUEUE.....

    Please kindly advise! [-o<

    Thanks very much!
    Rocopsa
  • Luc_VanDyckLuc_VanDyck Member, Moderator, Administrator Posts: 3,633
    Is your report executed through NAS? Add some MESSAGE-statements in your report and codeunit, and look into the event viewer if you can see these messages. That way, you can pinpoint the problem.
    No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)
  • rocopsarocopsa Member Posts: 38
    Thanks again Luc Van Dyck.

    I got the reason.

    It is because my codeunit contains Dataport. Eventhough I have given all the parameters (file path, sheet, etc) in the codeunit and then execute the dataport (that's why I only press the Run button and then the file will be exported), it is not being done by JOBQUEUE and NAS.

    Then, I try to skip using dataport and export the data using OUTSTREAM, the same Jobqueue successfully exported out the txt file. :D

    So, I feel dataport is not supported in Jobqueue eventhough all the necessary parameters are passed to it. Do you feel it is the fact? #-o

    Thanks in advance!
    Rocopsa
  • Luc_VanDyckLuc_VanDyck Member, Moderator, Administrator Posts: 3,633
    rocopsa wrote:
    So, I feel dataport is not supported in Jobqueue eventhough all the necessary parameters are passed to it. Do you feel it is the fact? #-o
    It's all in the docs: see http://msdn.microsoft.com/en-us/library/dd355014.aspx
    The following functions are not available in Microsoft Dynamics NAV Application Server:
    Form Data Type functions
    Dataport Data Type functions
    No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)
  • rocopsarocopsa Member Posts: 38
    Dear Luc Van Dyck,

    Thanks very much!!! Finally I can have the right way to go!!!

    So, I will change all the codeunits avoiding dataport.

    Thanks very much again!
    Rocopsa
Sign In or Register to comment.